ngx-facebook icon indicating copy to clipboard operation
ngx-facebook copied to clipboard

Logout not working

Open MTEKode opened this issue 7 years ago • 10 comments

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.

MTEKode avatar May 09 '17 07:05 MTEKode

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)

JohnVituli avatar May 11 '17 10:05 JohnVituli

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.

MTEKode avatar May 11 '17 10:05 MTEKode

@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?

danielptm avatar Aug 26 '17 09:08 danielptm

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?

theunreal avatar Sep 05 '17 13:09 theunreal

Any fixes for this?

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

marko1943 avatar Sep 22 '17 09:09 marko1943

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! :(

nbtai avatar Sep 27 '17 10:09 nbtai

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

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

ekzarov avatar Nov 17 '17 21:11 ekzarov

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();
    }
})		

gamunax avatar Jan 19 '18 14:01 gamunax

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.
      });
  }
);

yofr4nk avatar Mar 20 '19 20:03 yofr4nk

solved my problem, have a nice day :)

datpt46 avatar Jul 25 '22 01:07 datpt46