Facebook API Windows Universal 获取 WebAuthentication 结果
本文关键字:WebAuthentication 结果 获取 Universal API Windows Facebook | 更新日期: 2023-09-27 18:32:43
我想得到登录对话框的响应,如何得到它?我的目标是确保用户成功授予权限,并且我通过访问令牌获得与之交换的代码:
我的 GET 请求网址:
public async void getAccessByLogin()
{
string request_string = string.Format("https://www.facebook.com/dialog/oauth?client_id={0}&display={1}&response_type={2}&redirect_uri={3}&scope={4}",
Uri.EscapeDataString(RequestConstants.app_id.ToString()),
Uri.EscapeDataString("popup"),
Uri.EscapeDataString("token"),
Uri.EscapeDataString(WebAuthenticationBroker.GetCurrentApplicationCallbackUri().ToString()),
Uri.EscapeDataString("email"));
Uri request_uri = new Uri(request_string);
await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, request_uri);
}
要登录,我在getAccessByLogin方法中调用此方法:
await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, request_uri);
如果你看一下 WebAuthenticationBroker.AuthenticateAsync(),你会看到它返回 WebAuthenticationResult。例如,您可以像这样处理它:
WebAuthenticationResult result = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, request_uri);
if (result.ResponseStatus != WebAuthenticationStatus.Success)
await new MessageDialog("Problem!").ShowAsync();
else // do something