2

If I am logged into facebook.com, I expect a call to FB.getLoginStatus will return a status='not_authorized'. Instead it returns status='unknown', even if I pass true for the 'force' parameter.

If I call FB.login, and then call FB.getLoginStatus, I get status='connected'. Makes sense.

If I call FB.login, reload the page, and then call FB.getLoginStatus, I get status='unknown'. Does not make sense. If I add 'true' as the second parameter (i.e. force), I still get status='unknown'. (I expect status='not_authorized' in this case.)

There doesn't seem to be a way to get status='not_authorized' in practice.

Am I doing something wrong? Is this a bug in FB.getLoginStatus or its documentation?

Here is a minimal test page: http://pastebin.com/NqiBXni2

Context:

I am writing a website widget that displays posts for a public Facebook page. (This can be accessed without prompting the user via an app access token.) Each post has a "Like" / "Unlike" link. In order to determine whether to display "Like" or "Unlike", I need to know what the browsing user's Facebook ID is so that I can check whether it is in the post's list of likes.

David Foster
  • 6,931
  • 4
  • 41
  • 42

4 Answers4

8

Maybe you have third party cookies disabled.

David Canós
  • 1,806
  • 18
  • 19
1

And to elaborate slightly on David's answer, Facebook describes this as a "by design" result when 3rd party cookies are disabled.

Unfortunately, I'm not sure of the most graceful way of handling this -- at least in my site, I need an oath token to load some data.

sean
  • 83
  • 6
0

I had similar issue, even when the 3rd party cookie is not disabled. What I did to bypass is: if I get 'unknown' response, I will call FB.login and inside that call the FB.loginStatus again. This time, FB returned correct value.

Bennet Joseph
  • 308
  • 3
  • 6
0

Are you use http or https?

DO NOT use http be your DEV HOST!

Just use https and it works for me.

Ian
  • 74
  • 7