How would offline_access work after deprecation af

2019-02-19 14:00发布

I did some test, the result I found contradicts Facebook's documentation. https://developers.facebook.com/roadmap/offline-access-removal/

If we enable the "Deprecate offline access:" and ask for offline_access, at mobile client, we automatically get a token valid for 60 days, without upgrading the SDK. It seems Facebook made it easier for clients, no upgrade is needed. This is what is said on Facebook. "Apps migrating to this feature will no longer be asked for offline_access. They will be issued long lived access tokens which will expire if the user has not used the app in a while. " How long is the "a while" is not documented.

If I upgrade the SDK, extendingToken method is not triggered, because the token is valid for 60 days. If we force to extend the token, we got the following error from Facebook, which I have no clue what it means.

Error Domain=facebookErrDomain Code=10 "The operation couldn’t be completed. (facebookErrDomain error 10.)" UserInfo=0x1404bb70 {request_args=(
        {
        key = method;
        value = "auth.extendSSOAccessToken";
    },
        {
        key = sdk;
        value = ios;
    },
        {
        key = "sdk_version";
        value = 2;
    },
        {
        key = "access_token";
        value = AAACiLiBjLHABAOo3NZCSSLlRddFZCQUsky0q9sogtzHIFGpNNoeYUqtt2X2QUvxMg8AwsQqSLP3oe0cxUoLIXwVZC3xDGuBC3QOvFgELwZDZD;
    },
        {
        key = format;
        value = json;
    }
), error_code=10, error_msg=The access token was not obtained using single sign-on}

If we don't request "offline_access", the token expires in 2 hours.

What is your observation? Any thought? Any insight from Facebook?

1条回答
Luminary・发光体
2楼-- · 2019-02-19 14:46

The section marked 'If you were NOT previously asking for offline_access' in that document explains how to exchange that 2 hour token for a 60 day token: (note that the 2 hours and 60 days values could change in future)

https://developers.facebook.com/roadmap/offline-access-removal/#extend_token

Just access

https://graph.facebook.com/oauth/access_token?             
        client_id=APP_ID&
        client_secret=APP_SECRET&
        grant_type=fb_exchange_token&
        fb_exchange_token=EXISTING_ACCESS_TOKEN 

And the token returned will have a longer expiry (it may be the same token with a longer expiry or a new token, you should handle both cases)

查看更多
登录 后发表回答