0

I have a RoR app using omniauth. I want to allow the user to log out so that they can sign in with a different Facebook user, but no matter what I do, once a user logs into FB, it keeps them logged in.

I have tried: https://www.facebook.com/logout.php?next=&access_token=

To no avail. I also tried the reauth option for omniauth-facebook but that resulted in the user being brought to FB rather than to my specified redirect URL.

Eric
  • 5,815
  • 3
  • 25
  • 34

1 Answers1

0

Its easy, add this to your javascript initialization code: (after FB.init)

FB.logout(function(response) {
        FB.Auth.setAuthResponse(null, 'unknown');
        setTimeout('document.location.reload()',0);
      });

And the button of sign out:

<a href="/" onclick="FB.logout();">Logout</a>

Using the approach https://www.facebook.com/logout.php?next=&access_token= will make your user leave your page, as facebook won't redirect to your website again.

I hope this will solve your problem.

simo
  • 23,342
  • 38
  • 121
  • 218