newplayer
newplayer

Reputation: 35

How to generate a permanent (never expiring) facebook user access token?

As the title suggests im wondering how i could obtain a never expiring facebook user access token. Which i would need to create a page access token at a later date. I tried using their graph explorer tool but i could only make it go up to 2 months of expiry date and for my use case that wouldnt be ideal.

To shortly explain my use case, on our website im trying to implement a facebook sharing system where each user could share what they wanted i.e posts on their facebook page (we are not using facebook login and the user would just give acces from their own dev tool panel if thats the correct approach). I got this to work BUT only with a acces token that would expire in 2-3months. So a user having to re-authenicate with our service every 2-3 months isnt ideal and wouldnt really work for us. So is there a way i can refresh that token programtically or does the user have to give a new user access token every couple of months.

I have tried following this answer but with no luck Long Lived access token Facebook Page and many similar answers to this. There is also a suggestion that you should contact facebook if you want a never expiring access token which this user suggested Generate permanent access token Facebook API.

Now im wondering if it even is possible do that in 2021 and if there is anything i missed in regards how to generate said tokens or refresh them.

EDIT:

I used the following requests to get the extended access token.

https://graph.facebook.com/oauth/access_token?client_id=<your FB App ID >&client_secret=<your FB App secret>&grant_type=fb_exchange_token&fb_exchange_token=<your short-lived access token>

After i got the token i used

https://graph.facebook.com/me/accounts?access_token=<your long-lived access token> 

to get the extended access token.

Upvotes: 0

Views: 4003

Answers (1)

mef
mef

Reputation: 46

To get page access token that never expires, take the following steps:

  1. Get user token
  2. Make this token long-lived, e.g. by clicking "Extend access token" at the bottom of the page: https://developers.facebook.com/tools/debug/accesstoken/
  3. Then, use this token to get page access token.

In Access Token Debugger the token will be marked as "Expires: never"

Upvotes: 2

Related Questions