Facebook Api Windows 通用获取 WebAuthentication 结果
Facebook Api Windows Universal get WebAuthentication result
我想获取登录对话框的响应,如何获取?我的目标是确保用户成功授予权限,并通过访问令牌获取代码以与之交换:
我的 Url 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(),您会看到它 returns WebAuthenticationResult。你可以像这样处理它:
WebAuthenticationResult result = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, request_uri);
if (result.ResponseStatus != WebAuthenticationStatus.Success)
await new MessageDialog("Problem!").ShowAsync();
else // do something
我想获取登录对话框的响应,如何获取?我的目标是确保用户成功授予权限,并通过访问令牌获取代码以与之交换:
我的 Url 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(),您会看到它 returns WebAuthenticationResult。你可以像这样处理它:
WebAuthenticationResult result = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, request_uri);
if (result.ResponseStatus != WebAuthenticationStatus.Success)
await new MessageDialog("Problem!").ShowAsync();
else // do something