0
votes

Renew (or Exchange )access token (without admin user interaction) from the access token which is about to expire

Hello,

I have access tokens for the users which is stored in the database. A CRON job runs every day and fetch details of new products and post to application fan page behalf of page.

But as the facebook tokens expires every 60 days it is needed to be renewed. But the issue is that in the renewal process user interaction should not be involved.

We need to exchange the token which is about to expire with the new token. There is no any documentation for the same.

We want the CRON job to check which are the tokens about to expire and renew them immediatly without user intervention.Is there any way to make it possible without ping the below url daily

https://graph.facebook.com/oauth/access_token?client_id=APPID&client_secret=APPSECRET&grant_type=fb_exchange_token&fb_exchange_token=TOKEN

Any help would be appreciable.

Thanks!!

1
If this is about using page access tokens, then get an extended one – those don’t expire by default. developers.facebook.com/docs/facebook-login/access-tokensCBroe
According to the stackoverflow.com/questions/17282559/…. Page token also expires after 60 daysuser3060970
Would you please read the documentation that I linked to!?!CBroe

1 Answers

1
votes

renew them immediatly without user intervention

Renewing user access token is not possible without user intervention. The user must interact, and you'll get fresh normal access token and exchange that with the extended token. According to the documentation:

Even the long-lived access token will eventually expire. At any point, you can generate a new long-lived token by sending the person back to the login flow used by your web app - note that the person will not actually need to login again, they have already authorized your app, so they will immediately redirect back to your app from the login flow with a refreshed token - how this appears to the person will vary based on the type of login flow that you are using, for example if you are using the JavaScript SDK, this will take place in the background, if you are using a server-side flow, the browser will quickly redirect to the Login Dialog and then automatically and immediately back to your app again.

After doing the above you will obtain a new short-lived token and then you need to perform the same exchange for a long-lived token as above.

If page access token can do your deed, you can get the never-expiring page token. See this answer: What are the Steps to getting a Long Lasting Token For Posting To a Facebook Fan Page from a Server