3

We are working in Java with restfb to perform actions over facebook. The first thing we do is to get an extended access token using the access token that we obtain after a php oauth process. The code to obtain the extended token is-

FacebookClient facebookClient = new DefaultFacebookClient(shortLivedToken)
AccessToken extendedAccessToken = facebookClient.obtainExtendedAccessToken(apiKey, secretKey, shortLivedToken);
extendedToken = extendedAccessToken.getAccessToken();

For what I read and experienced, that extended token expires in two months. Is there any way to obtain an extended access token, with restfb, that never expires?

Sahil Mittal
  • 20,697
  • 12
  • 65
  • 90

1 Answers1

2

No. You can not have a never-expiring user access token. In order to get refresh the token, the user needs to visit the app again.

More details on access tokens here.

Note: You can have a never-expiring page-access-token, as mentioned here: https://stackoverflow.com/a/18322405/1343690

Community
  • 1
  • 1
Sahil Mittal
  • 20,697
  • 12
  • 65
  • 90
  • If we perform an action in facebook with the long-lived access token, is the token refreshed? The idea is that the user logs in the app with credentials that have nothing to do with facebook, and they put the facebook credentials in order to get the extended token. –  Nov 26 '13 at 12:01
  • Simply by performing an action with the extended token wont refresh it. Instead, you can do this- every time a user visit your app, you get the access token, extend it and save it. In this way, the token will never expire if the user visits the app once in 2 months. Hope you get it – Sahil Mittal Nov 26 '13 at 12:05