4
votes

I'm able to get an access token that's good for 60 days, but I'm not able to get the expiration time extended. I'm doing this to be able to get access to Facebook pages through a single user. Here's my process.

I make a call to: https://www.facebook.com/dialog/oauth?response_type=token&client_id=APP_ID&scope=read_stream,publish_stream,manage_pages,read_insights,create_event&redirect_uri=REDIRECT_URL

I then call to this URL using the token I got from the URL above: 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

I've tried this multiple times over the weekend, and in every single instance, I get the same access token, but the expiration is not updated. I've done this by accessing the URLs in my browser.

Am I missing anything to be able to renew the expiration?

3

3 Answers

1
votes

I think the page admin user will have to come back to your app in that 60 days to get a new access token with the extended time on it. I don't think you can (or should) be allowed to extend the access token by application only.

See: https://developers.facebook.com/docs/offline-access-deprecation/

Note: The user must access your application before you're able to get a valid "authorization code" to be able to make the server-side oAuth call again. Apps will not be able to setup a background/cron job that tries to automatically extend the expiration time, because the "authorization code" is short-lived and will have expired.

0
votes

I just encountered this problem. The issue ended up being that "deprecate offline access" was disabled in my FB application. When disabled, the extending tokens always returned a short lived token. When enabled, I was able to get long lived access tokens.

0
votes

The offline access has been deprecated by the facebook developers, but you can still extend your access token life upto 60 days by passing your app id, app secret and current access token to the following url: 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

Note: The EXISTING_ACCESS_TOKEN must be a valid accesss token(not expired one).