Reputation: 213
I am facing one serious issue on chrome for facebook access token. Following is the code from where i get user id and access token. This access token is later used for accessing various facebook functions.
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
uid = response.authResponse.userID;
accessToken = response.authResponse.accessToken;
} else if (response.status === 'not_authorized') {
In chrome, when i load the page first time.. It comes fine with access token. but when i refresh it few times, sometime it gives me access token as 0. Due to this nothing works. CAn anyone please help me out of this?
David
Upvotes: 3
Views: 467
Reputation: 310
You may want to try setting the forcing a roundtrip to Facebook's server on page load so that you can always get the most up to date status of the user. The JavaScript SDK automatically caches the login status the first time the user views the page, but you can override it like this:
FB.getLoginStatus(function(response) {
// this will be called when the roundtrip to Facebook has completed
}, true);
Just make sure that the forced roundtrip doesn't add too much unnecessary latency! You can read more on the page for FB.getLoginStatus(). The section about the forced roundtrip is about halfway down the page.
Happy coding!
Upvotes: 1