如何在不让用户完全退出 Facebook 的情况下撤销应用程序授权?
每当我尝试“断开”用户与使用 Facebook JavaScript SDK 进行身份验证的网站的连接时,它会完全破坏用户的 Facebook 会话(例如,如果他们在单独的选项卡上登录 Facebook,则会要求他们登录)再次)。我有以下客户端代码:
$('#logout').bind('click', function(){
if(FB.getSession() !== undefined){
//FB.logout();
// instead of logging out of facebook, just disconnect them
FB.api({
method: 'Auth.revokeAuthorization'
}, function(response){
console.log('auth revoke', response);
});
}
});
window.fbAsyncInit = function() {
FB.init({
appId: MYAPPIDHERE
,status: true
,cookie: true
,xfbml: true
});
FB.Event.subscribe('auth.sessionChange', function(response){
console.log(response);
location = location.href;
});
};
(function() {
var e = document.createElement('script');
e.async = true;
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
假设 jQuery 在页面上。 FB.api 调用成功,但似乎比应有的“更强大”。它基本上与调用 FB.logout() 具有相同的效果。
我做错了什么,或者我应该提交一个错误?
谢谢!
Whenever I try to "disconnect" the user from my website that uses the Facebook JavaScript SDK for authentication, it instead completely destroys the user's Facebook session (if they were logged into Facebook on a separate tab, for example, they would be asked to login again). I have the following client-side code:
$('#logout').bind('click', function(){
if(FB.getSession() !== undefined){
//FB.logout();
// instead of logging out of facebook, just disconnect them
FB.api({
method: 'Auth.revokeAuthorization'
}, function(response){
console.log('auth revoke', response);
});
}
});
window.fbAsyncInit = function() {
FB.init({
appId: MYAPPIDHERE
,status: true
,cookie: true
,xfbml: true
});
FB.Event.subscribe('auth.sessionChange', function(response){
console.log(response);
location = location.href;
});
};
(function() {
var e = document.createElement('script');
e.async = true;
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
Assume that jQuery is on the page. The FB.api call is successful, but seems to be "more powerful" than it should be. It basically has the same effect as calling FB.logout().
What am I doing wrong, or should I instead file a bug?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,我的实际代码实际上是在调用 FB.logout() 。哎呀!
Turns out, my actual code was actually calling FB.logout() regardless. Oops!