Search code examples
facebookcookiesoauthfacebook-graph-apiaccess-token

Getting Access Token from cookies to use with Facebook Graph API


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.


Solution

  • 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.