Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fortybelowzero/15c147165eb147f4854475df6c3046e6 to your computer and use it in GitHub Desktop.
Save fortybelowzero/15c147165eb147f4854475df6c3046e6 to your computer and use it in GitHub Desktop.

Notes on creating a facebook API access token that doesnt expire for accessing page posts (via a long-lived access token)

Just collating notes on how to create a non-expiring facebook API access token for accessing posts from a facebook page as I have to create them occasionally for the a social posts website plugin i wrote (but not often enough to remember how to do it :-)

Assuming we have a facebook app created already, note down app ID and secret and head over to:

https://developers.facebook.com/tools/explorer

Select the App you want to create the access token for from the drop down list. Select Get Token-> Get User Access Token

Will show a popover of security scopes. For access to a pages post select "Publish pages" and "Manage pages, click the "Get Access Token" button

Now go to: https://developers.facebook.com/tools/accesstoken Press the debug button next to the user token , and choose the option to create the "Extend access token" (which is good for 2 months) Copy the long-lived token.

To convert it to a never expiring token, go back to https://developers.facebook.com/tools/explorer , and paste the long lived token in the Access Token field. Change the api end point to /me/accounts and click submit - this will show a non-expiring access token.

To verify the token wont expire, copy it, go back to https://developers.facebook.com/tools/accesstoken and debug the access token.

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