[英]How can I log out of Facebook when using OmniAuth?
I have a RoR app using omniauth. 我有一个使用omniauth的RoR应用程序。 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. 我想允许用户注销,以便他们可以与其他Facebook用户登录,但是不管我做什么,一旦用户登录FB,它就会使他们保持登录状态。
I have tried: https://www.facebook.com/logout.php?next= &access_token= 我已经尝试过: 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. 我还尝试了omniauth-facebook的reauth选项,但是这导致用户被带到FB而不是我指定的重定向URL。
Its easy, add this to your javascript initialization code: (after FB.init) 很简单,将其添加到您的javascript初始化代码中:(在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. 使用方法https://www.facebook.com/logout.php?next=&access_token=将使您的用户离开您的页面,因为facebook不会再次重定向到您的网站。
I hope this will solve your problem. 我希望这能解决您的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.