Search code examples
facebook-graph-apiaccess-token

How to get Facebook Long-lived page access token


Following https://developers.facebook.com/docs/facebook-login/guides/access-tokens/get-long-lived/

and using the graph explorer https://developers.facebook.com/tools/explorer

  • I select my app (and add the right permissions)
  • I generate a Short Lived User Token
  • I call /me?fields=id,name
  • I remember id in the result as my App Scoped User Id
  • I call /oauth/access_token?grant_type=fb_exchange_token&client_id=xxx&client_secret=yyy&fb_exchange_token={Short Lived User Token}
  • I remember access_token in the result as my Long Lived User Token
  • I call /{App Scoped User ID}/accounts?access_token={Long Lived User Token}

But all that returns is

{
  data: []
}

What am I doing wrong ?


Solution

  • I needed to add the scope business_management to my (short lived) user access token - and then go through the whole process again.

    I think that's what solved it. If anyone understands why, please let me know in the comments.

    What helped me along the way was the token debugger that I didn't know existed: https://developers.facebook.com/tools/debug/accesstoken