FB.getLoginStatus never fires the callback function in Facebook's JavaScript SDK

后端 未结 6 760
被撕碎了的回忆
被撕碎了的回忆 2021-01-04 19:04

The simple thing of calling FB.init (right before ) and then FB.getLoginStatus(callback) doesn\'t fire the callback funct

相关标签:
6条回答
  • 2021-01-04 19:31

    I had the exact same problem, and I solved it disabling "Secure Browsing" in the Facebook Security settings. Keeping Secure Browsing on forces the pages as "https", but I had no "Secure Canvas URL" set up, and this gave me a lot of errors in the console as well.

    Hope this may help someone :)

    0 讨论(0)
  • 2021-01-04 19:32

    I had this same problem in Firefox 3.5 on Windows, but only on the very first log in to the page (probably because it was a slower machine and there was some weird timing issues going on).

    I fixed it by forcing FB to refresh the login status cookie every time it checks:

    FB.getLoginStatus(callback, true); //second argument forces a refresh from Facebook's server. 
    

    Without "force=true", sometimes it wouldn't fire the callback.

    0 讨论(0)
  • 2021-01-04 19:32

    In my experience, getLoginStatus() never calls the callback in Firefox when third-party cookies are disabled.

    The original poster mentioned his application is hosted on http://localhost. I've never had luck with that, and believe it will cause problems.

    Just today, I've had problems where getLoginStatus is not calling the callback on any browser, unless the user is actually connected to the app! I'm hoping this is a bug on facebook's end that they will solve.

    0 讨论(0)
  • I also ran into this issue specifically in Chrome. I tried calling it on page load and after a user-initiated action with no success.

    It turned out that it was not a cross-domain issue. The getLoginStatus() call was being blocked by the Un-Passwordise extension in Chrome. As soon as I disabled the extension, it worked perfectly, even on page load.

    More info about this issue here: Chrome-only cross-domain scripting errs in Facebook iFrame App upon FB.Login(..)

    0 讨论(0)
  • 2021-01-04 19:43

    I understand that this question is a little old now, but I ran across it searching for solutions.

    Double-check what you have set in your Facebook app configuration under the section "Website with Facebook Login". The Site URL domain must match the domain your page with the FB.getLoginStatus (and other related auth Javascript) is served from.

    After hours of struggling, I realized that I could not reuse an existing app configuration I had on a new server and had to create a new app to handle the website login for this new server.

    The other answers are probably equally valid in your specific case, but since there may be others like me who have struggled for a while on this, hopefully this gives you one other place to check. Making a new app with the correct Site URL was the answer in my particular case.

    0 讨论(0)
  • 2021-01-04 19:46

    Yet another possibility for FB.getLoginStatus not firing its callback is when using a "test" user account that has not been authorized to view that application. Its pretty bad that facebook doesn't give you any error messages. I have also seen failed callbacks on bad appIds and redirectUrls.

    0 讨论(0)
提交回复
热议问题