[英]FB.login is always asking my password (even if I'm already logged in)
I'm playing with Facebook Javascript SDK in order to implement a Facebook Connect action. 我正在使用Facebook Javascript SDK来实现Facebook Connect操作。 It's already working but the problem is that every time that I try to login again on my application the user has to reenter its facebook password.
它已经在工作,但是问题在于,每次我尝试再次登录应用程序时,用户都必须重新输入其Facebook密码。
I'm sure that there is an option to do this step without entering the password if you are already logged in in facebook (I have seen this in lots of web pages). 我敢肯定,如果您已经登录了facebook(我在很多网页上都看到过此信息),则可以选择执行此步骤而无需输入密码。 But how?
但是如何? The documentation http://developers.facebook.com/docs/reference/javascript/FB.login/ and even the source code does not explain how to do this:
文档http://developers.facebook.com/docs/reference/javascript/FB.login/甚至源代码都没有说明如何执行此操作:
"@param opts {Object} ( optional ) Options to modify login behavior." “ @param选择{Object}( 可选 )选项来修改登录行为。”
My implementation right now is like this: 我现在的实现是这样的:
function login(){
FB.login(function(response) {
if (response.authResponse) {
$(".fb_login").hide();
$(".fb_logout").show();
FB.api('/me', function(response) {
register_user(response.id, response.name);
});
} else {
alert('User cancelled login or did not fully authorize.');
}
});
}
And I call to FB.init like this: 我这样调用FB.init:
FB.init({
appId : 'xxxxxxxxx', // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
Maybe it has to be a change in the FB.init or some kind of option while calling to FB.login. 调用FB.login时,可能必须是FB.init中的更改或某种选项。 Any ideas?
有任何想法吗?
Thanks in advance, Raimon Bosch. 在此先感谢Raimon Bosch。
There is a method FB.getLoginStatus which you can use to check if user is already loggedin: 有一个FB.getLoginStatus方法,可用于检查用户是否已经登录:
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
var accessToken = response.authResponse.accessToken;
//you are loggedin
} else if (response.status === 'not_authorized') {
//loggedin but not authorized your app
} else {
// the user isn't logged in to Facebook.
}
});
Did you mean something like that 你的意思是那样的吗
在PP设置中检查“ 强制Web OAuth重新身份验证” facebbok开发人员>您的应用程序> facebook登录>设置>将“强制Web OAuth重新身份验证”设置为“否”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.