I have an application that refreshes Facebook applications info at some time, let's say once a day and writes them in database. Some of the Pages that the application tries to get information from are Age restricted and the situation gets complicated.
So far I've found that one way to do this is to get the info of the page with user access_token.
Ex.: https://graph.facebook.com/BrandCigarettes?access_token={user_access_token}
But that is impossible since the application should run itself once a day and the token is time limited (default two hours) and offline access tokens are not available anymore.
Is there any way to do this?
Normal tokens usually expire after two hours, but with that short live token, you can request a new long live token, this token will have a duration of 60 days.
After you get that you just need to save the user_id and the respective extended token on your database, so if you just want to get some information of some pages you don'te need to do that for every user of your app, you just need to do for yourself, you can create a private area on your app where you go every 59 days just to renew the token.
To exchange your short-lived access token for a long one just do a request to the graph API
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
On this question the accepted answer explains how to do that without using the C# facebook sdk
Feed Offline Access
As CBroe commented, I also advise you to read the facebook documentation about extended tokens
https://developers.facebook.com/roadmap/offline-access-removal/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With