windows-8 - 如果从 foursquare 传递到 Facebook,WebAuthenticationBroker 将挂起

标签 windows-8 windows-runtime oauth-2.0 foursquare facebook-oauth

我编写了一个基于 XAML 的 WinRT 应用程序,它通过 WebAuthenticationBroker.AuthenticateAsync 调用连接到 foursquare。这是授权码:

        public async Task<string> FsqAuthenticate()
    {
        var fsqAuthUrl = string.Format(
            "https://foursquare.com/oauth2/authenticate?client_id={0}&response_type=code&redirect_uri={1}&display=webpopup", 
            ClientId, RedirectUri);
        var requestUri = new Uri(fsqAuthUrl, UriKind.RelativeOrAbsolute);
        var redirUri = new Uri(RedirectUri, UriKind.RelativeOrAbsolute);
        string authCode = string.Empty;
        string authToken = string.Empty;

        try
        {
            ResponseErrorMsg = string.Empty;

            WebAuthenticationResult WebAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync(
                WebAuthenticationOptions.None,
                requestUri, redirUri);

            if (WebAuthenticationResult.ResponseStatus == WebAuthenticationStatus.Success)
            {

如果用户选择直接通过 foursquare 进行身份验证,或通过 foursquare 注册,则效果很好。然而,foursquare OAuth 页面为用户提供了通过 Facebook 登录/注册的选项。如果选择,初始 Facebook 登录屏幕将正确显示;用户可以输入用户名/密码并选择“登录”按钮;然后窗口一片空白。看来控制权正在被传递给 Facebook 的弹出窗口,提示授予权限。但是,WebAuthenticationBroker 没有显示此内容。出于所有意图和目的,WebAuthenticationBroker 已挂起。

是否存在针对此行为的解决方法?

最佳答案

我终于得到了微软关于这个问题的回复:

Facebook Connect won’t work as it requires communication between multiple pages but the Webauth Broker can only have one active at a time. The issue here is that foursquare launches a popup for facebook authorization and waits for the popup to complete and an event to fire on the first foursquare page. In the case of webauth, we navigate to all popups inline, so the first page that launches the popup will be gone and there is no event that can be sent back to the first page.

结果是,除了编写自己的登录过程并完全绕过 WebAuthenticationBroker(我最终这样做)之外,没有解决方法。

TL;DR:WebAuthenticationBroker 已损坏,目前没有计划修复它。

关于windows-8 - 如果从 foursquare 传递到 Facebook,WebAuthenticationBroker 将挂起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12388221/

相关文章:

windows-8 - 在 WinJS 中以编程方式停止视频捕获

c++ - native C++ 将 IIterable 传递给 WinRT

Java - Reader 无法解析

node.js - 我应该在哪里存储 code_verifier(使用 PKCE 的 oauth 2.0 代码授权流程)

windows-8 - 如何将 Windows Mobile 6 ActiveSync 到 Windows 8

multithreading - C# 应用程序中使用的 C++ WinRT DLL 中出现 "Activating a single-threaded class from MTA is not supported"错误

windows-runtime - C++/CX 中是否可以替代 C# 的等待? WIN10

python - CertificateValidationUnsupported 在 Python 2.4 上使用 oauth2/httplib2

xaml - Metro XAML - TemplateBinding 和 SolidColorBrush 的问题

c# - 如何将资源嵌入到 appx 包中?