Skip to content

Generating Facebook access token

istewart edited this page May 26, 2018 · 10 revisions
Clone this wiki locally

Take a deep breath...

...

...now go.

APP_ID = application ID, located in the top toolbar on the app's homepage.

  1. Sign up as developer: https://developers.facebook.com/
  2. Create a business page: https://www.facebook.com/pages/creation/
  3. Create an app: https://developers.facebook.com/apps. The values don't matter.
  4. Activate the app by setting it to "Live" on the app's page: https://developers.facebook.com/apps/APP_ID
  5. Fill out the basic settings for the app: https://developers.facebook.com/apps/APP_ID/settings Again, the values don't matter, you just need to provide some proof of completion for approval. This also includes adding a platform for the app, which can just be a dummy URL.
  6. Submit the app for review to gain basic access for Ads Management: https://developers.facebook.com/apps/APP_ID/review-status/ You can skip this step if you just need a short-term token, but for a long-term token your app will need ads_management permission.
  7. Once the app is approved, the Marketing API will be activated and you can generate a never-ending token as follows. Generate an access token with ads_management and ads_read permission: https://developers.facebook.com/apps/APP_ID/marketing-api/tools/
  8. Generate a user access token with the manage_page and publish_pages permission (click on the drop-down menu on the right and choose "Get user access token"): https://developers.facebook.com/tools/explorer/
  9. Find the user access token and click "debug": https://developers.facebook.com/tools/accesstoken/
  10. Click "extend access token" and copy the generated token.
  11. Paste the token into the "Access Token" field, and submit the call "me/accounts": https://developers.facebook.com/tools/explorer/
  12. Copy the value for the "access_token" field, paste it here: https://developers.facebook.com/tools/debug/accesstoken/, then click "debug".
  13. The token expire value should be "never". Go here: https://developers.facebook.com/tools/accesstoken/, click on "debug" for the user access token, and then click "extend access mode."

Note! When you're making API calls with this token, you need to use the ad account ID instead of your user ID, otherwise the access token won't work. You can get the ad account ID by querying for "me/adaccounts" on the Graph API, using the token from your app: https://developers.facebook.com/tools/explorer/