Why doesn't Facebook JavaScript authentication work on a specific computer?

I have a website that uses the JavaScript JavaScript API for Facebook so that users can log in to the Ruby on Rails app via Facebook. When a user clicks to log in or log out, the Facebook code authenticates and then triggers an event and delivers a cookie with authentication parameters. Cookies are sent to my server and I use it for authentication. This has been working for a while.

// 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(); }); 

I recently received a new computer, and my site does not work from this computer. The Facebook login interface seems to work, the auth.sessionChange event is auth.sessionChange , but it looks like a cookie is never delivered, so the page goes into an endless loop for receiving an authentication event, refreshing the page without cookie and repeating. The problem seems to be that this is the only computer that happens regardless of which browser I use and which OS I use.

It works on:

  • Friendly PC using Internet Explorer
  • Friendly PC using Firefox Friend PC
  • PC friends using Firefox on Ubuntu 10.10 in VirtualBox
  • Another computer on the same subnet as the new computer
  • Booting a new computer from a 64-bit Ubuntu 10.10 CD

Does not work:

  • New computer using Internet Explorer
  • New computer with Chrome.
  • New Computer Using Firefox
  • New computer using Firefox in Ubuntu 10.10 in VirtualBox

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

Update: It began to work as mysteriously as it failed.

+5
javascript cookies facebook
source share
2 answers

It could be the same thing I had to deal with . In your code, I do not see 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 }); }; 

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

0
source share

Try top.location.reload();

It looks like you can use some kind of jQuery. If so, which version are you using?

It might also be worth upgrading to the new JavaScript SDK with OAuth 2.0. Migration has made many bugs for my applications.

0
source share

All Articles