Bootstrap FreeKB - Facebook Graph API - Get Access Token
Facebook Graph API - Get Access Token

Updated:   |  Facebook Graph API articles

This assumes you are already created an app in https://developers.facebook.com. If not, check out my article Getting Started with Facebook Graph API. Let's say you have an app named default that has Access ID 123456789 and Secret 123456789abcdefg.

 

It's important to recognize that there are different types of tokens.

  • App Access Token
  • Client Access Token
  • Page Access Token
  • System User Access Token
  • User Access Token

 

Here is how you could submit a GET request using curl to get an App Access Token.

]$ curl --request GET --url "https://graph.facebook.com/oauth/access_token?client_id=123456789&client_secret=123456789&grant_type=client_credentials"
{"access_token":"123456789|mhEopnzo0bAqVV06LT7RvRsg4K8","token_type":"bearer"}

 


According to this Stack Overflow Answer, "You can only get a User Access Token with user interaction, not by curl". In other words, perhaps only the https://developers.facebook.com GUI can be used.

  1. Go to https://developers.facebook.com and select My Apps.
  2. Select your App.
  3. Select Tools > Graph API Explorer.

By default, the query should be setup to GET v18.0/me?fields=id,name. Select Submit and this should return your User ID, something like this.

{
  "id": "1234567890123456",
  "name": "John Doe"
}

 

And User Access Token, something like this.

EAANROE66DrsBOy1TiJVQPEPEZAgo2Iap7QzdKEGRfJBW30drpIpkprZB4N5MRxDfZCoLh4OQZCCDgPqVxFEO39YDTIZCmChr9b3QcDr5MxPSjxvnY4Q1uPpMZCgG6Tr0FsZAW2vJD3qo5LpYZCu2JE2VhBUZCAPnZCCnysHlvca9QQ9BS2cvXxccHmUGPEKml4ncE0BYrfh7bI9ZAL9M7sLBgZDZD

 


Here is how you could submit a GET request using curl to get a Page Access Token using the User Access Token.

curl --request GET --url "https://graph.facebook.com/{your-user-id}/accounts?access_token={user-access-token} 

 

 

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 3e94ea in the box below so that we can be sure you are a human.