退出“离线访问权限”后,在Facebook上注销/切换用户 [英] Logout/switch-user on Facebook after deprecation of Offline Access Permission

查看:149
本文介绍了退出“离线访问权限”后,在Facebook上注销/切换用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

5月1日,Facebook的不赞成离线访问权限,Web应用程序可以轻松延长OAuth访问令牌的持续时间(60天)。



但是,如果应用程序在网络上,并希望提供一个切换用户 / strong>选项,通常是注销 - >登录,那么访问令牌将失效,对于offline_access,根本就不能替代。



问题:是否有一种方法来保持有效的访问令牌(60天),但仍然允许注销或多个用户在单个浏览器上登录或在请求时强制登录提示登录(为Facebook提供Switch用户登录页面)?



还是鼓励您不再提供注销选项?

解决方案

这可能是出于安全原因而不行,但是你尝试过结构化注销URL而不指定访问令牌?也就是说,例如:




  • 如果您使用的是PHP SDK,可以编写自己的 getLogoutUrl(...)方法,或者只是传递一个空的access_token,如 $ facebook-> getLogoutUrl(array('access_token'=>'')) ;


  • 如果您使用JS SDK,您将无法使用 FB。 logout(),需要访问令牌。相反,您可以提供自己的:




  FB.provide('UIServer.Methods',{
'auth.logout':{
url:'logout.php',
transform:function(a){
var xdRelation = FB.UIServer.getXdRelation(a.params);
a.params.next = FB.UIServer._xdResult(a.cb,a.id,xdRelation,true);
return a;
}
}
});

如果执行上述代码,理论上应该将FB.logout的行为更改为不再传递access_token。公平警告:我没有自己测试。否则,只需将用户发送到 http://facebook.com/logout.php?next=SOME_URL ,看看是否没有access_token。


With Facebook deprecating offline access permissions on May 1st, web applications can easily extend the duration of OAuth access token (for 60 days).

But if the application is on the web and wants to provide a "Switch user" option, most often a logout -> login, then the access token are invalidated, and there is no substitute at all for offline_access anymore.

Question: is there a way to keep valid access tokens (for 60 days) but still allow logout or multiple users to login on a single browser or a way to "force login prompt" when requesting login (for Facebook to offer Switch user on the login page)?

Or are we encouraged not to offer a logout option anymore?

解决方案

It's possible this won't work for security reasons, but have you tried constructing the logout URL without specifying an access token? That is, for example:

  • If you're using the PHP SDK, either write your own version of the getLogoutUrl(...) method or just pass in an empty access_token like $facebook->getLogoutUrl(array('access_token' => ''));

  • If you're using the JS SDK, you will not be able to use FB.logout(), which requires an access token. Instead, you could provide your own:

FB.provide('UIServer.Methods', {
    'auth.logout': {
        url: 'logout.php',
        transform: function(a) {
            var xdRelation = FB.UIServer.getXdRelation(a.params);
            a.params.next = FB.UIServer._xdResult(a.cb, a.id, xdRelation, true);
            return a;
        }
    }
});

If you execute the above code, in theory it should change the behavior of FB.logout to no longer pass an access_token. Fair warning: I haven't tested it myself. Otherwise, just send the user to http://facebook.com/logout.php?next=SOME_URL and see if that works without an access_token.

这篇关于退出“离线访问权限”后,在Facebook上注销/切换用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆