Take the 2-minute tour ×

I'm quite confused with the access token from facebook..here is how I obtain the user's access token and use it to get data from graph API

window.fbAsyncInit = function() {
        appId       : 'app ID',
        status      : true, 
        cookie      : true,
        xfbml       : true,
        oauth       : true,     
    FB.Event.subscribe('auth.authResponseChange', getStatus);

    function getStatus(response) {
        if ( response.status === 'connected' ) {
            var accessToken = response.authResponse.accessToken;
            console.log("accessToken = " + accessToken);

                dataType    : "jsonp",
                type        : "GET",
                url     :   "https://graph.facebook.com/me/albums?access_token=" + accessToken,
                success : function(data) {
                        console.log(index + ": " + value);  

However, I always get an empty data. After I visit the graph API documentation here: https://developers.facebook.com/docs/reference/api/ and click on one of the graph links, I notice that the access token generated there is always different from what I retrieve from my code. For example, the current access token in the graph api documentation is


and the one in console log is


I think that I may have done this the wrong way. Can anyone help explain to me how to retrieve data from graph API in a correct way?

Any kinds of help will be appreciated. Thanks in advance :)

share|improve this question

3 Answers 3

up vote 2 down vote accepted

Run this URL with your authToken first:


You'll almost certainly only see basic permissions in the response, which is why you aren't getting the data from your call to the user's album.

You'll then want to run your user through the Authentication Process, making sure you request the permissions you need (probably 'user_photos' in your case).

More info is available in those two links. Good luck!

share|improve this answer
Hey thanks..the reason that I always get blank data is because it is not listed in the permission..At first, I thought that as long as I have the access token that I can access any of the user's information..thanks a lot :) –  Felix Perdana Jul 10 '12 at 10:14

access token will never be the same. So that behaviour is correct.

Back to your problem , I think its mostly scope related issue.

share|improve this answer
so how do I retrieve the data from graphs API using those access token? –  Felix Perdana Jul 10 '12 at 9:26

I had developed a application using facebook c# sdk, In that application i did it like this:

  1. when a post is to be submitted , redirect the user to facebook (with some parameters like appid, app-secret, auth-token and redirect-url);
  2. Facebook will ask the user to login with his credentials.
  3. When the user is logged in, facebook will redirect back to the redirect-url. (with the authtoken and a new auth-code).
  4. Then we should use this auth-code, app-id and app-secret and obtain the user-access-token. (This is done by doing a rest api call to the url https://graph.facebook.com/oauth/access_token?client_id=client_id&redirect_uri=redirect_uri&client_secret=client_secret&code=auth-code This will return the user-token and expiry time for the token
  5. And then we can post using this user-access-token to the fb.

Initially i had misunderstood the auth-code and used it as the user-access-token, and i always got the result as unauthorised token . Please check whether this will help you or not.

share|improve this answer

Your Answer


