1

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

SimonSays
  • 10,867
  • 7
  • 44
  • 59
  • You can use the Offline Access permission as described here - http://stackoverflow.com/a/2705505 – Abhinav Manchanda Feb 08 '12 at 12:44
  • 1
    i know about the offline_access permission. this is, however, not the preferred way to handle token expiration according to the FB doc and does also not change the fact that the favored way to handle this situation does not work. https://developers.facebook.com/docs/offline-access-deprecation/ – SimonSays Feb 08 '12 at 18:45
  • did you come up with any solution? i have the same problem and my investigations led to the same point: resolveInfo is null, that is why extendAccessToken does not work... news on this are highly appreciated! – Stefan Jul 23 '12 at 21:02
  • no not really. i ended up using the offline_access permission anyways. – SimonSays Jul 23 '12 at 21:15

1 Answers1

2

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.

Tonn
  • 106
  • 5
  • i've already used the offline permission, which is of course not perfect. this one looks good though, i will try to do it this way in the next version of the app. – SimonSays Feb 28 '12 at 02:08
  • @SimonSays , I am also having trouble with the extendAccessTokenIfNeeded() function and I beginning to think it isn't just me! Did you have success with the method above? – Mel Apr 08 '12 at 00:47
  • i haven't had the opportunity to try it yet, but it looks like it is the usual web app access, so it should work i guess. let me know if you try it and it works. – SimonSays Apr 08 '12 at 04:39