Skip to content

Instantly share code, notes, and snippets.

@lucnap
Last active October 22, 2021 09:53
Show Gist options
  • Save lucnap/9bc0a616b95180e7d938e963e220b638 to your computer and use it in GitHub Desktop.
Save lucnap/9bc0a616b95180e7d938e963e220b638 to your computer and use it in GitHub Desktop.
How to get a Facebook Page Access Token that doesn't expire Never!
How to get a Facebook Page Access Token that doesn't expire Never!
- Go to http://developers.facebook.com/tools/explorer/
- Get a User Access Token with a permission "manage_pages"
- Convert this short-lived access token into a long-lived one by making this Graph API call:
https://graph.facebook.com/v2.6/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>
- Make a call Graph API:
https://graph.facebook.com/v2.6/<your personal account FB user id>/accounts?access_token=<your long-lived access token>
- The returned access_token has no expiration unless you change your password or not more admin of the target page or deauthorize FB page
source:
http://stackoverflow.com/questions/17197970/facebook-permanent-page-access-token
http://stackoverflow.com/questions/12168452/long-lasting-fb-access-token-for-server-to-pull-fb-page-info
@phartley
Copy link

When attempting to make the call to convert the short-lived to the long-lived I'm receiving this error. Any ideas?

{type: "http", message: "unknown error"}

@adithyamaheshb
Copy link

I too get the same error. To be more specific:

Uncaught SyntaxError: Unexpected token :

@tpriyanshu
Copy link

I get

{
    "data": []
}

as the output

@haseebtirur
Copy link

I am not seeing manage_pages under the permission dropdown, even though I am an admin of the page? Please help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment