本文整理匯總了C#中Parse.ParseUser.LinkWithAsync方法的典型用法代碼示例。如果您正苦於以下問題:C# ParseUser.LinkWithAsync方法的具體用法?C# ParseUser.LinkWithAsync怎麽用?C# ParseUser.LinkWithAsync使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Parse.ParseUser
的用法示例。
在下文中一共展示了ParseUser.LinkWithAsync方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: LinkAsync
/// <summary>
/// Links a <see cref="ParseUser" /> to a Facebook account, allowing you to use Facebook
/// for authentication, and providing access to Facebook data for the user.
///
/// The user will be logged in through Facebook's OAuth web flow, so you must supply a
/// <paramref name="webView"/> that will be navigated to Facebook's authentication pages.
/// </summary>
/// <param name="user">The user to link with Facebook.</param>
/// <param name="webView">A web view that will be used to present the authorization pages
/// to the user.</param>
/// <param name="permissions">A list of Facebook permissions to request.</param>
/// <param name="cancellationToken">The cancellation token.</param>
public static async Task LinkAsync(ParseUser user,
WebBrowser webView,
IEnumerable<string> permissions,
CancellationToken cancellationToken) {
authProvider.Permissions = permissions;
LoadCompletedEventHandler loadCompleted = (_, e) => authProvider.HandleNavigation(e.Uri);
webView.LoadCompleted += loadCompleted;
Action<Uri> navigate = uri => webView.Navigate(uri);
authProvider.Navigate += navigate;
await user.LinkWithAsync("facebook", cancellationToken);
authProvider.Navigate -= navigate;
webView.LoadCompleted -= loadCompleted;
}
示例2: LinkAsync
/// <summary>
/// Links a <see cref="ParseUser" /> to a Facebook account, allowing you to use Facebook
/// for authentication, and providing access to Facebook data for the user.
///
/// The user will be logged in through Facebook's OAuth web flow using the Windows
/// WebAuthenticationBroker.
/// </summary>
/// <param name="user">The user to link with Facebook.</param>
/// <param name="permissions">A list of Facebook permissions to request.</param>
/// <param name="cancellationToken">The cancellation token.</param>
public static async Task LinkAsync(ParseUser user,
IEnumerable<string> permissions,
CancellationToken cancellationToken) {
var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
authProvider.Permissions = permissions;
Action<Uri> navigate = async uri => {
var result = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None,
uri,
FacebookAuthenticationProvider.ResponseUrl);
if (result.ResponseStatus != WebAuthenticationStatus.Success) {
cts.Cancel();
} else {
authProvider.HandleNavigation(new Uri(result.ResponseData));
}
};
authProvider.Navigate += navigate;
try {
await user.LinkWithAsync("facebook", cts.Token);
} finally {
authProvider.Navigate -= navigate;
}
}
示例3: LinkAsync
/// <summary>
/// Links a <see cref="ParseUser" /> to a Facebook account, allowing you to use Facebook
/// for authentication, and providing access to Facebook data for the user.
/// </summary>
/// <param name="user">The user to link to a Facebook account.</param>
/// <param name="facebookId">The user's Facebook ID.</param>
/// <param name="accessToken">A valid access token for the user.</param>
/// <param name="expiration">The expiration date of the access token.</param>
/// <param name="cancellationToken">The cancellation token.</param>
public static Task LinkAsync(ParseUser user,
string facebookId,
string accessToken,
DateTime expiration,
CancellationToken cancellationToken) {
return user.LinkWithAsync("facebook",
authProvider.GetAuthData(facebookId, accessToken, expiration),
cancellationToken);
}