pc035860 / angular-easyfb

Super easy AngularJS + Facebook JavaScript SDK.
MIT License
440 stars 69 forks source link

FB.logout() called without an access token. #43

Closed greemwahr closed 9 years ago

greemwahr commented 9 years ago

I keep getting this error when I used the method outlined in your plunker. The thing is that i'm using your solution with Ionic framework but also I am using Firebase for login authentication. I tried using there method for log-out but it doesn't completely log me out of the Facebook API. Thus the reason I'm trying to use yours for complete logout will I keep Firebase for login due some other requirements I have in my app. Thanks.

pc035860 commented 9 years ago

Hi @shadowsyntax ,

Sorry for the late response. I'm not familiar with either Ionic or Firebase, but I suggest that you can try wrapping .logout() with .getLoginStatus(), which might solve the called without an access token error.

ezfb.getLoginStatus(function (response) {
  if (response && response.status === 'connected') {
    ezfb.logout();
  }
});

The thing is that Facebook JS SDK actually tries to maintain an active access token in it, which seems can only obtained through calling .getLoginStatus().

See also: FB.logout() called without an access token. javascript sdk

greemwahr commented 9 years ago

Hello @pc035860, I tried your trick and it works fine now. My apologies for getting back to you so late, been tackling some other programming issues.

Thanks a lot.

dragipostolovski commented 1 year ago

To use the access token with the FB.logout method, you need to ensure that you have obtained the access token during the login process and that it is available when you want to log out the user.

FB.logout(function(response) {

    if ( 'connected' === response.status ) {
        window.location.href = data.render.logout_url;
    } else {
        console.log( 'There has been an error.' );
    }
}, {
    access_token: data.render.accessToken
});