SL4 Facebook应用程序不再检索access_token [英] SL4 Facebook application no longer retrieves access_token

查看:77
本文介绍了SL4 Facebook应用程序不再检索access_token的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个SL4退出浏览器应用程序,该应用程序已经使用了几个月.截至目前,看来它不再能从Facebook上获取一个access_token了.我正在使用facebook-c#-sdk v4.1.1.一些部分代码发布在下面:

I have an SL4 Out of Browser application which has been working for several months. As of right now, it appears it will not longer retrieve an access_token from Facebook. I am using facebook-c#-sdk v4.1.1. Some partial code is posted below:

    void FacebookLoginBrowser_Loaded(object sender, RoutedEventArgs e)
    {
        if (!loggedIn)
        {
            LoginToFacebook();
        }
    }

    private void LoginToFacebook()
    {

        dynamic parms = new System.Dynamic.ExpandoObject();
        parms.display = "popup";
        parms.client_id = appId;
        parms.redirect_uri = successUrl;
        parms.cancel_url = failedUrl;
        parms.scope = requestedFbPermissions;
        parms.type = "user_agent";

        loggingInUri = fbApp.GetLoginUrl(parms);

        FacebookLoginBrowser.Source = (loggingInUri);

    }

以下是浏览器重定向到的html页面的代码:

Below is the code for the html page the browser is redirected to:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
    Complete
</body>
<script type="text/javascript">
    window.external.notify(window.location.href);
</script>
</html>

然后javascript会触发以下内容:

The javascript then fires the following:

    private void FacebookLoginBrowser_ScriptNotify(object sender, NotifyEventArgs e)
    {

        if (e.Value != "Failed")
        {
            string url = e.Value.Replace('#', '?');

            url = HttpUtility.UrlDecode(url);

            Uri ur = new Uri(url);

            string[] str = ur.Query.Split('&');
            access_token =  str[0].Split('=')[1];

            if(!String.IsNullOrEmpty(access_token)){
                fbApp = new FacebookApp(access_token);

                App app = (App)Application.Current;
                app.Fuid.fbApp = fbApp;

                loggedIn = true;
                loginSucceeded(e);
            }

        }

        if (fbApp.Session == null)
        {

            failedLogin();
        }
    }

似乎不再包含通常包含access_token值的查询字符串.使用Fiddler,我能够看到来自Facebook的重定向,该重定向确实包含access_token值.我不确定它在哪里丢失.让我知道是否有人需要任何其他信息.谢谢!

It appears the querystring which normally contains the access_token value is not longer there. Using Fiddler, I was able to see the redirect from facebook which does contain the access_token value. I am not sure where it is being lost at. Let me know if any one needs any additional information. Thanks!

推荐答案

Facebook关于查询字符串结构的行为已发生变化.在 http://facebooksdk.codeplex.com/discussions/261528 中对此进行了讨论.我的代码使用WPF而不是Silverlight.我不确定同一问题是否适用于Silverlight控件.

There has been a change in Facebook behavior regarding the structure of the query string. This is discussed in http://facebooksdk.codeplex.com/discussions/261528. My code uses WPF and not Silverlight; I'm not sure whether the same issue applies to the Silverlight control.

请注意,Facebook C#SDK的当前版本为 http://facebooksdk.codeplex.com/.

Note that the current version of Facebook C# SDK is 5.0.40 per http://facebooksdk.codeplex.com/.

另请参阅 Facebook客户端流是否仍然存在发出访问令牌?.

这篇关于SL4 Facebook应用程序不再检索access_token的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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