Facebook 客户端流程是否仍会提供访问令牌? [英] Does Facebook Client-Side Flow still give out access tokens?

查看:29
本文介绍了Facebook 客户端流程是否仍会提供访问令牌?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经能够创建一个 WebBrowser 控件,导航到登录 URL(例如http://www.facebook.com/dialog/oauth/?response_type=token&display=popup&scope=user_about_me&client_id=179873125388138&redirect_uri=http%3a%2f%2fwww.facebook.com%2fconnect%2flogin_success.html"),然后使用下面的代码(来自 Facebook-C#-SDK 示例代码)捕获 Navigated 事件并提取访问令牌.然而,最近,这似乎只是重定向到 RedirectURL,而不是附加访问令牌.Facebook 在 2011 年 2 月至 2011 年 6 月之间处理身份验证流程的方式是否发生了某种变化?也许这是一个 IE9 的问题?

I used to be able to create a WebBrowser control, navigate to the login URL (e.g. "http://www.facebook.com/dialog/oauth/?response_type=token&display=popup&scope=user_about_me&client_id=179873125388138&redirect_uri=http%3a%2f%2fwww.facebook.com%2fconnect%2flogin_success.html"), then use the code below (from Facebook-C#-SDK sample code) to catch the Navigated event and extract the access token. Lately, however, it seems that this just redirects to the RedirectURL, and doesn't append the access token. Has there been some sort of change in how Facebook handles the auth flow between February and June 2011? Maybe this is an IE9 problem?

奇怪的是,我可以手动将普通的 IE9 浏览器发送到相同的 URL,并且可以很好地附加访问令牌.只有当我使用 WebBrowser.Navigated 事件以编程方式执行此操作时,我才不再看到令牌.

The strange thing is, I can manually send a regular IE9 browser to the same URL and the access token is appended fine. It's only when I do this programmatically using the WebBrowser.Navigated event that I no longer see the token.

谢谢,乔恩

    private void webBrowser_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
    {
        FacebookOAuthResult oauthResult;
        if (FacebookOAuthResult.TryParse(e.Uri, out oauthResult))
        {
            this.FacebookOAuthResult = oauthResult;
            this.DialogResult = oauthResult.IsSuccess;
        }
        else
        {
            this.FacebookOAuthResult = null;
        }
    }

推荐答案

我很确定这是 http://facebooksdk.codeplex.com/discussions/261528,Facebook 行为变化与 WPF WebBrowser 控件问题之间的交互.通过切换到 WinForms,我能够解决我的问题.该链接讨论了另一种方法,该方法保留在 WPF 中,但添加了对 FacebookOAuthClient.ExchangeCodeForAccessToken() 的调用.

I'm pretty sure this is http://facebooksdk.codeplex.com/discussions/261528, an interaction between a change in Facebook behavior and an issue with the WPF WebBrowser control. I was able to work around my issue by switching to WinForms. The link discusses an alternate approach which stays with WPF but adds a call to FacebookOAuthClient.ExchangeCodeForAccessToken().

这篇关于Facebook 客户端流程是否仍会提供访问令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆