简体   繁体   English

使用OmniAuth时如何注销Facebook?

[英]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.

相关问题 如何通过gem OmniAuth Facebook / Twitter注销社交网站 - How to log out social sites via gem OmniAuth Facebook/Twitter 在使用OmniAuth时,如何指定用户的Facebook帐户需要哪些访问权限? - How can I specifiy what access I need from my user's Facebook accounts when using OmniAuth? 使用Omniauth Identity时如何设置身份验证表? - How can I set the authentications table when using Omniauth Identity? 如何通过Omniauth / Facebook登录请求传递参数? - How can I pass parameters through a Omniauth/Facebook login request? 如何在使用devise + omniauth + rails 3时清除facebook会话和cookie? - How to clear facebook session and cookie when using devise + omniauth + rails 3? 尝试将omniauth facebook 与rails 集成并部署到heroku 时无法登录 - Can't log in when trying to integrate omniauth facebook with rails and deploying to heroku 注册用户首次使用Facebook登录-Omniauth - Registered user log in for the first time using Facebook - Omniauth 通过Facebook Omniauth进行设计-如何使用API​​进行身份验证? - Devise with Facebook Omniauth - How to authenticate using API? Omniauth和Devise今天早上开始失败,当用Facebook进行身份验证时? - Omniauth and Devise started to fail out of the blue, this morning, when authenticating with Facebook? 使用Omniauth Facebook和Ajax - Using Omniauth facebook and ajax
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM