Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Open Graph API Examples - How to get the access token?

Facebook has some great-looking examples of Open Graph requests here:

https://developers.facebook.com/docs/reference/api/examples/

The problem is that since I don't have an access token, most of the examples just return

{    "error": {       "message": "An active access token must be used to query information about the current user.",       "type": "OAuthException",       "code": 2500    } } 

I understand access tokens, but how do I get the token so that I can experiment with these example requests?

like image 994
ohthepain Avatar asked Oct 24 '13 13:10

ohthepain


People also ask

How do I get my Exchange token on Facebook?

Using a valid, long-lived access token, your server sends a request to get a code from Facebook. Facebook sends a code back to your server and you securely send this code to the client. The client uses this code to request a long-lived token from Facebook.


1 Answers

As long as you only want to test...

Use the Graph API Explorer to generate a token with the permissions you want.

Selection Permissions pop-up

Don't hesitate to select all of them.

Then, just copy/paste the token at the end of each graph.facebook.com URL. For instance:

https://graph.facebook.com/v1.0/me/friends?access_token=<ACCESS_TOKEN> 

The day you want to get the access taken for an app...

Start by reading this doc.

like image 90
Stéphane Bruckert Avatar answered Oct 26 '22 04:10

Stéphane Bruckert