Getting Access Token from cookies to use with Facebook Graph API

16,813

Solution 1

All the docs you're going to need are here: https://developers.facebook.com/docs/authentication/

If you just want a single access token for yourself to test some things in the API, you could use the Graph API Explorer ( https://developers.facebook.com/tools/explorer ) to generate an access token for you for that app and copy/paste it to your code.

Be sure to include the 'offline_access' permission to get a token which won't quickly expire.

Solution 2

Simply you can't!
You need to create an application to be able to generate an access_token (after a successful authentication/authorization). More about this here.

Share:
16,813
Joker Thief
Author by

Joker Thief

Joseph Heller; Helen Keller.

Updated on June 04, 2022

Comments

  • Joker Thief
    Joker Thief almost 2 years

    Assuming I have a user logged in to Facebook (Cookies are saved in the browser's cache), what is the simplest way to get its access token? I'm experimenting with Facebook's Graph API, and I don't want to bother with creating an application in order to get access tokens (at least not now).

    If I remember correctly, a few days ago I went to http://graph.facebook.com/me on my browser (while being logged in), which redirected me to http://graph.facebook.com/me?access_token=..., but now I get that instead (and no redirection):

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

    Unfortunately, I couldn't rely on previously answered questions, since I strongly believe things changed very recently.