本文整理汇总了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);
}