zyra / ngx-facebook

Angular TypeScript Wrapper for Facebook SDK
http://zyra.github.io/ngx-facebook/
MIT License
209 stars 70 forks source link

Logout not working #77

Open MTEKode opened 7 years ago

MTEKode commented 7 years ago

Hi, I have a issue with logout function. Init function:

let initParams: InitParams = {
  appId: '000000000000',
  xfbml: true,
  status: true,
  cookie: true,
  version: 'v2.9'
};
this.fb.init(initParams);

Logout function:

this.fb.logout()
  .then(response => {
    console.log(response)
  })
  .catch((error: any) => {
    console.error(error)
  });

Thats looks like works but it is not. The console show: Object {authResponse: Object, status: "unknown"} And it should be: Object {authResponse: null, status: "unknown"} Thats why if you refresh the page you continues logged.

JohnVituli commented 7 years ago

you can try this

this.fb.getLoginStatus()
      .then(res=>{
        if(res && res.status == 'connected'){
          this.fb.logout()
            .then(res=>{console.log(res)})
            .catch(this.handleError);
        }
      }).catch(this.handleError)
MTEKode commented 7 years ago

Hi, Thats is not working, I think the cookie is the problem but I need it. I believe that sdk works over facebook cookie so if you do not delete them you still logged but if you delete it, you get logged out from facebook. I want logout from my web but not from facebook.

Thanks for you answer.

danielptm commented 7 years ago

@mtoribio I am having the same problem, when I call the fb.logout() function I am not logged out of Facebook nor my app. Is there a workaround for this? Or is a solution for this in sight?

theunreal commented 7 years ago

Same here.

When refresing the page - it log out Using cookie: true, solves it, but then it's impossible to log out.

@zyra @ihadeed any idea?

marko1943 commented 6 years ago

Any fixes for this?

Edit: I also noticed that the getLoginStatus() isn't working

nbtai commented 6 years ago

I have the same problem! Even I can't get the Object {authResponse: Object, status: "unknown"} in the response of logout function. Another case, can we have any solution to logout only from my application, this.fb.logout() logs me out complitly from facebook.com page! :(

ekzarov commented 6 years ago

The same... Can it be related to this stuff:

https://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus#servers

gamunax commented 6 years ago
let initParams: InitParams = {
            appId: 'xxxxx',
            xfbml: true,            
            version: 'v2.11',
            cookie: true        
        };
this.fb.init(initParams);

my solution was to place a cookie: true

this.fb.getLoginStatus()
.then(res => {              
    if ( res && res.status === 'connected' ) {
    this.fb.logout();
    this.borrarLocal();
    }
})      
yofr4nk commented 5 years ago

I had the same problem, try this one:

FB.api(
  '/me/permissions',
  'DELETE',
  {},
  function(response) {
      // Here fb should remove the token.
      // response should be "success: true"
      FB.logout(() => {
               // Here logout.
      });
  }
);
datpt46 commented 2 years ago

solved my problem, have a nice day :)