开发者

Does Facebook Client-Side Flow still give out access tokens?

开发者 https://www.devze.com 2023-03-14 16:54 出处:网络
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=17

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#-SD开发者_开发问答K 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?

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.

Thanks, Jon

    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;
        }
    }


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().

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号