Developers Manual > SDK Integration > Facebook > Facebook API References in JavaScript > Facebook-getAccessToken

.getAccessToken()

Returns the access token granted to your app when the user most recently authorized it; otherwise, an empty string.

Example

1
2
3
4
5
6
7
8
var facebook = plugin.FacebookAgent.getInstance();
var token = facebook.getAccessToken();
    if (token){
        cc.log("AccessToken: " + token);
    } else {
        cc.log("No valid access token from the current user");
    }
});

Sign up for our newsletter to keep up with the latest developments, releases and updates for Cocos2d-x.