Steps taken from http://stackoverflow.com/a/28418469/933621 (Dude you're a life saver!)
-
Create Facebook App
- Go to My Apps.
- Click "+ Add a New App".
- Setup a website app.
You don't need to change its permissions or anything. You just need an app that wont go away before you're done with your access token.
-
Get User Short-Lived Access Token
- Go to the Graph API Explorer.
- Select the application you want to get the access token for (in the "Application" drop-down menu, not the "My Apps" menu).
- Click "Get Token" > "Get User Access Token".
- In the pop-up, under the "Extended Permissions" tab, check "manage_pages".
- Click "Get Access Token".
- Grant access from a Facebook account that has access to manage the target page. Note that if this user loses access the final, never-expiring access token will likely stop working.
Token that appears in the "Access Token" field is your short-lived access token.
-
Generate Long-Lived Access Token
- Make a call via Postman to https://graph.facebook.com/v2.8/oauth/access_token?grant_type=fb_exchange_token&client_id={app_id}&client_secret={app_secret}&fb_exchange_token={short_lived_token}
The response should look like this: access_token=ABC123&expires=5182959
ABC123 will be your long-lived access token. You can put it into the Access Token Debugger to verify. Under "Expires" it should have something like "2 months".
-
Get User ID
- Using the long-lived access token, make a GET request to
https://graph.facebook.com/v2.8/me?access_token={long_lived_access_token}
The id field is your account ID. You'll need it for the next step.
-
Get Permanent Page Access Token
- Make a GET request to
https://graph.facebook.com/v2.8/{account_id}/accounts?access_token={long_lived_access_token}
The JSON response should have a data field under which is an array of items the user has access to. Find the item for the page you want the permanent access token from. The access_token field should have your permanent access token. Copy it and test it in the Access Token Debugger. Under "Expires" it should say "Never".