3

To get the Access Token,

GET: https://graph.facebook.com/oauth/access_token?
        client_id=YOUR_APP_ID
       &client_secret=YOUR_APP_SECRET
       &redirect_uri=uri

I tried with below GET method in Graph API Explorer

/oauth/access_token?client_id=XXXXX&client_secret=XXXXXXXXXXXXX&redirect_uri=http://XYZ.com/

But here I am getting error:

{
  "error": {
    "message": "Missing authorization code",
    "type": "OAuthException",
    "code": 1
  }
}

Can you please suggest, What should be pass in of Code Parameter.

/oauth/access_token?client_id=XXXXXX&client_secret=XXXXXXXXXXXXXXX&redirect_uri=http://XYZ.com/&code=??
Jagadeesh
  • 1,630
  • 8
  • 24
  • 35

2 Answers2

4

Your GET parameters are incorrect. Instead use this:

https://graph.facebook.com/oauth/access_token?client_id=XXXXX&client_secret=XXXX&grant_type=client_credentials

Your'e missing the

grant_type=client_credentials

parameter/value combination, which is required in order to receive access token.

Lev
  • 3,719
  • 6
  • 41
  • 56
  • By using yours above url, i got response like. access_token=|SJgcG4272bQmKz2Lbx_K5HRaQYU But while using this access_token in below url, https://graph.facebook.com/search?limit=25&offset=50&type=user&q=srihari&access_token=1416550685225787|SJgcG4272bQmKz2Lbx_K5HRaQYU Now, i am getting error like: { "error": { "message": "(#200) Must have a valid access_token to access this endpoint", "type": "OAuthException", "code": 200 } } – Jagadeesh Sep 24 '13 at 07:34
  • I'm having the same exact problem as you – Hakim Dec 14 '13 at 16:41
0

This returns an app level oauth token but you did not yet introduce the 'scope' parameter which authorizes a list of permissions:

https://graph.facebook.com/oauth/access_token?client_id=<client-id>&client_secret=<client-secret>&redirect_uri=http://example.com/&scope=<comma-separated-list-of-permissions>&grant_type=client_credentials

For list of the available permissions you can find them when you select "Get Access Token" from your App's Facebook Explorer dashboard -

https://developers.facebook.com/tools/explorer/<client-id>/
Lorena Nicole
  • 499
  • 2
  • 9
  • 21