Unable to extend facebook access token

I am trying to extend my facebook access token, and following is what I did. However, i wasn't able to get the token extended, and when I check the facebook accesstoken debugger it still shows that the token is expiring in an hour.

any ideas?

    private string appId = "my app id";
    private string appSecret = "my app secret";
    private string returnUrl = "http://localhost:1868/callback";
    private string _scope = "user_about_me,publish_stream,user_videos,user_photos";

    [Test]
    public void GetFacebookLoginUrl()
    {
        var fb = new FacebookClient();
        dynamic result = fb.GetLoginUrl(
            new
                {
                    client_id = appId,
                    client_secret = appSecret,
                    redirect_uri = returnUrl,
                    response_type = "code",
                    scope = _scope
                }
            );
    }

    [Test]
    public void exchangeCodeForAccessToken()
    {
        var fb = new FacebookClient();
        dynamic result = fb.Get("oauth/access_token", new
        {
            client_id = appId,
            client_secret = appSecret,
            redirect_uri = returnUrl,
            code = "got the code after user accepts the request"
        });
    }


    [Test]
    public void ExtendExpiryTimeOfAccessToken()
    {
        var fb = new FacebookClient();
        dynamic result = fb.Get("oauth/access_token", new
        {
            client_id = appId,
            client_secret = appSecret,
            grant_type = "fb_exchange_token",
            fb_exchange_token = "token from preview method"
        });
    }

Solution

after de-authorize the app from the users' accounts everything start making sense. One thing to note tho, the code above actually gets a "long lived" access token back which is valid for 60 days and it can not be extended.

if a Facebook client-side authentication is used, then one can extend it using the "ExtendExpiryTimeOfAccessToken" sample.


If you initially started developing the application and signing in months ago before the offline access depreciation it is possible your affected by this bug.

https://developers.facebook.com/bugs/341793929223330

If you are affected you need to de-authorise the application and then try again, this doesn't affect new users.

链接地址: http://www.djcxy.com/p/61614.html

上一篇: 获取Facebook的应用程序访问令牌

下一篇: 无法扩展Facebook访问令牌