调用FB.logout()而不使用访问令牌. JavaScript SDK [英] FB.logout() called without an access token. javascript sdk
问题描述
对此完全迷失,并且文档并没有真正给与任何对此的见识...
Totally lost on this and docs don't really give any insight on this...
在我的应用程序中使用Facebook Javascript SDK,并使用以下登录按钮代码:
Using the Facebook Javascript SDK in my app with this login button code:
<fb:login-button scope="manage_pages,read_insights,ads_management" autologoutlink="true" size="large"></fb:login-button>
根据文档,autologoutlink=true
参数会在用户登录后将login
按钮变为log out
.我想保留此功能,而不要编写自己的按钮代码
As per the docs, autologoutlink=true
param turns the login
button to log out
once the user is logged in. I want to keep this functionality and not write my own button code
此事件调用FB.logout
,但仍在回调中返回错误消息
This event calls FB.logout
but still returns the error message in the callback
FB.Event.subscribe('auth.logout', function(response) {
FB.logout(function(response) {
// FB.logout() called without an access token.
});
});
我想使用Facebook Login Widget,而不是我自己的按钮进行登录,因此关于同一主题的其他答案无济于事.我不明白我应该如何通过access_token来证明我有权注销...
I would like to use the Facebook Login Widget and not my own button for login, so the other answers on the same subject don't help. I don't understand how I'm supposed to pass the access_token to prove I'm authorized to logout...
推荐答案
显然,这是不可能的,至少我无法确定.快速解决方案是从自定义Log Out
按钮调用此函数:
Apparently this isn't possible, at least in no way I can figure out. Quick solution is call this function from a custom Log Out
button:
function fbLogoutUser() {
FB.getLoginStatus(function(response) {
if (response && response.status === 'connected') {
FB.logout(function(response) {
document.location.reload();
});
}
});
}
页面重新加载向Facebook发出另一个请求,然后Facebook看到未授权状态并从浏览器中删除cookie,这反过来又使access_token无效.因此,这会将用户从网站和Facebook中注销.
The page reload makes another request to Facebook which then sees the unauthorized state and removes the cookie from the browser which in turn invalidates the access_token. So this logs out the user from the site and from Facebook.
这篇关于调用FB.logout()而不使用访问令牌. JavaScript SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!