I am using the Facebook JS SDK to let users connect their facebook account to my website but I ran into a weird problem.
it seems when you follow these steps:
- connect for the first time with your fb account,
- authorize my app,
- go in another tab in your browser to the facebook website,
- remove my app,
- go back to my website tab in your browser
- click the connect button again
The FB.getLoginStatus still returns response.status as 'connected' until you refresh my website's tab, only then it shows response.status as 'not_authorized'.
even FB.login is returning response.status as 'connected' until I refresh my window (even though Im calling FB.logout before this)
Why do I need to refresh my window before it shows as 'not_authorized' and how do I go about solving this?
edit: I am using OAuth functionality
That's because the 'FB.getLoginStatus' response object is cached by the SDK.
If you want to solve this problem, just call FB.getLoginStatus with the second parameter set to true.
FB.getLoginStatus(function(response) {
// this will be called when the roundtrip to Facebook has completed
}, true);
https://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus/