简体   繁体   English

FB.login总是询问我的密码(即使我已经登录)

[英]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.

相关问题 FB.login()没有要求给定的权限 - FB.login() not asking for given permissions fb.login响应始终返回true - fb.login response always returns true 我正在尝试使用FB.login获取唯一的电子邮件,名称和位置 - 但Facebook API始终要求用户提供“朋友列表”访问权限 - I'm trying to do FB.login to get the get only email, name and location - but Facebook API always requests user for “friend lists” access permission 如果用户已登录FB,如何阻止我的Facebook登录弹出窗口出现? - How do I stop my Facebook login popup from appearing if user is already logged into FB? FB.login仅适用于我的开发者帐户 - FB.login only works with my developers account FB.login()响应不一致 - FB.login() response is inconsistent 如果用户已经登录,则隐藏“ FB登录”按钮 - Hide the FB Login button if user already logged in Facebook注销/断开FB.login()在用户已连接时调用 - Facebook logout/disconnect FB.login() called when user is already connected 不使用 FB.login() 登录 - Login without using the FB.login() 从网络应用程序调用FB.login()时,官方的Facebook iOS应用程序总是崩溃 - Official Facebook iOS app always crashes when calling FB.login() from web app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM