Search code examples
facebookfacebook-graph-apifacebook-access-token

How to get Facebook access token


According this documentation i tried to send get request to graph api

curl -X GET "https://graph.facebook.com/oauth/access_token
  ?client_id={your-app-id}
  &client_secret={your-app-secret}
  &grant_type=client_credentials"

but I am getting an error message

{
    "error": {
        "message": "Missing redirect_uri parameter.",
        "type": "OAuthException",
        "code": 191,
        "fbtrace_id": "AFBj5BLV5WZ0ZTlT62XuaVb"
    }
}

Does anybody know what am I doing wrong? Thanks.

PS: I dont want to log in user I want to download Instagram images for FB app....


Solution

  • In your case, I seen you need a application in Facebook Apps
    Now you can see in https://developers.facebook.com/apps/

    With example:
    You make a application
    After it, Facebook will regenerate App ID and App Secret
    Then Input them to

    curl -X GET "https://graph.facebook.com/oauth/access_token
      ?client_id={your-app-id}
      &client_secret={your-app-secret}
      &grant_type=client_credentials"
    

    Example:

    curl -X GET "https://graph.facebook.com/oauth/access_token
      ?client_id=336055786532989
      &client_secret=46ff578663d95d62fa22f257cabe62ce
      &grant_type=client_credentials"