为什么Facebook JavaScript验证在特定计算机上不工作? [英] Why wouldn't the Facebook JavaScript authentication work on a specific computer?

查看:124
本文介绍了为什么Facebook JavaScript验证在特定计算机上不工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Facebook JavaScript API的网站,允许用户通过Facebook登录Ruby on Rails应用程序。当用户单击登录或注销时,Facebook代码进行身份验证,然后引发事件并提供具有身份验证参数的Cookie。该cookie被发送到我的服务器,我用它进行身份验证。这已经工作了一段时间。

I have a site that uses the Facebook JavaScript API to allow users to log in to a Ruby on Rails application through Facebook. When a user clicks to log in or log out, Facebook code does the authentication and then raises an event and supplies a cookie with authentication parameters. The cookie is sent to my server, and I use it to authenticate. This has been working for some time.

  // Connnect with Facebook.
  $('.fbLogout').click(function() {
      FB.logout();
  });
  $('.fbLogin').click(function () {
      FB.login();
  });
  FB.init({appId: '163691796982300', status: true, cookie: true, xfbml: true});
  FB.Event.subscribe('auth.sessionChange', function() {
      location.reload();
  });

我最近有一台新电脑,我的网站不能从这台电脑工作。 Facebook登录界面似乎可以工作, auth.sessionChange 事件被提出,但它看起来像是从未提供的cookie,所以页面进入无限循环接收身份验证事件,刷新页面没有cookie和重复。问题似乎在这台单机上,无论使用哪种浏览器,以及我使用的是哪种操作系统。

I recently got a new computer, and my site doesn't work from this computer. The Facebook login UI seems to work, the auth.sessionChange event is raised, but it looks like the cookie is never supplied and so the page goes into an endless loop of receiving an authentication event, refreshing the page with no cookie and repeating. The problem seems be on this single computer and happens regardless of which browser I use, and which OS I use.

它适用于:


  • 朋友的PC使用Internet Explorer

  • 朋友的PC使用Firefox朋友的电脑

  • Ubuntu 10.10中的Firefox在VirtualBox中

  • 与新电脑相同的子网中的另一台电脑

  • 从Ubuntu 10.10 Live CD 64位

  • Friend's PC using Internet Explorer
  • Friend's PC using Firefox Friend's PC
  • Friends PC using Firefox in Ubuntu 10.10 in VirtualBox
  • Another PC in the same subnet as new computer
  • New computer booting from Ubuntu 10.10 live CD 64-bit

无效:


  • 新使用Internet Explorer的计算机

  • 使用Chrome的新电脑

  • 使用Firefox的新电脑

  • Ubuntu 10.10在VirtualBox中

  • New computer using Internet Explorer
  • New computer using Chrome
  • New computer using Firefox
  • New computer using Firefox in Ubuntu 10.10 in VirtualBox

这可能是由我的网卡或网络配置引起的吗?

Could this somehow be caused by my network card or network configuration?

更新:
它开始工作就像失败一样神秘。

Update: It started working just as mysteriously as it was failing.

推荐答案

这可能是同样的事情我不得不处理。在代码中我看不到异步初始化:

This could be the same thing I had to deal with. In your code I can't see the asynchronous initialization:

window.fbAsyncInit = function() {
    FB.init({
          appId  : fb_appId,
          status : true, // check login status
          cookie : true, // enable cookies to allow the server to access the session
          xfbml  : true,  // parse XFBML
          oauth : true //enables OAuth 2.0
    });
};

这是非常重要的,以保证Facebook JavaScript SDK在调用init方法之前已经完全加载。因此,它可能突然开始工作,因为浏览器已经缓存了JavaScript文件。

This is very important to guarantee that the Facebook JavaScript SDK is fully loaded before you call the init method. Therefore it may suddenly have started working, because the browser already cached the JavaScript file.

这篇关于为什么Facebook JavaScript验证在特定计算机上不工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆