SimonSays
SimonSays

Reputation: 10977

Facebook access token can not be extended

i am using the facebook android sdk, which i just downloaded from github.

i understand that the access token is just valid for a very limited time and needs to be extended every time the app gets started as described in the doc. https://developers.facebook.com/docs/mobile/android/build/#extend_token

there are 2 problems with this:
1) the function extendAccessTokenIfNeeded() does not update when the token has already expired (after just one or two hours!)

2) the other problem, when i bypass the first one, is that the required intent for extending the token can not be found.

from the SDK source:

Intent intent = new Intent();
intent.setClassName("com.facebook.katana",
                    "com.facebook.katana.platform.TokenRefreshService");
...
ResolveInfo resolveInfo =
            context.getPackageManager().resolveActivity(intent, 0);
if (resolveInfo == null) {
        return false;
}

resoveInfo is allways null here.

any ideas on how to extend the token? i don't wanna call the authenticate() function all the time the toked expires. that would totally destroy the user experience!

thx Simon

Upvotes: 1

Views: 2637

Answers (1)

Tonn
Tonn

Reputation: 106

The facebook android sdk make a connection to the refresh token service to extend the access token, but the service is part of Facebook android app, which means that your app user needs to install native Facebook first.

Alternative:

  1. You can use graph api /auth/access_token described in developers.facebook.com/docs/offline-access-deprecation/

  2. I try the request from facebook iOS SDK and it works:

GET api.facebook.com/method/auth.extendSSOAccessToken?access_token=

or in json format. GET api.facebook.com/method/auth.extendSSOAccessToken?format=json&access_token=

Please prefix https:// to all the urls above.

Upvotes: 2

Related Questions