How do you revoke app authorization without logging the user completely out of Facebook?
Whenever I try 开发者_JAVA技巧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!
Turns out, my actual code was actually calling FB.logout() regardless. Oops!
精彩评论