For my application, I need to be able to get some datas from 0-x FB accounts for each person.
I have the authentication process working, I get the different access tokens, but they become invalid very quickly because, when the user logs in as a different account, the token from the previous one becomes invalid.
Problem is, I need to get the datas I want all at the same time, so I can’t ask them to login with their multiple accounts each time they come on the website…
If anyone has an idea…
Thanks for your help =)
You can increase 2 table columns in your app namely short_access_token & long_access_token for each user.
Once user authenticates your app, an access token is generated, store it in short_access_token. Then pass this access token to:
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
Once you run this, an access token with 60 days validity will be generated. Store it in long_access_token. Now, use this long_access_token for 60 days.
You can generate long lived access token only once a day i.e. the first time. Use this long lived access token for your tasks (if you’ve already got the permission).
Ref: https://developers.facebook.com/roadmap/offline-access-removal/