Why does FB.getLoginStatus() return response status 'unknown'

brown powder

We are developing a website at www.bodecanada.com. One of the login methods we provide is facebook. We also try to keep track of whether the user is logged into facebook or not when refreshing the page or opening the site in a new tab. We do this by calling FB.getLoginStatus() (from the Facebook js sdk). However, we are finding that in a few cases–for example, when opening the site in a new tab in Safari–the response status that comes back from FB.getLoginStatus is ‘unknown’. The Facebook SDK documentation says this about the ‘unknown’ status:

FB.getLoginStatus() allows you to determine if a user is logged in to
Facebook and has authenticated your app. There are three possible
states for a user:

  1. The user is logged into Facebook and has authorized your application. (connected)
  2. The user is logged into Facebook but has not authorized your application.(not_authorized)
  3. The user is either not logged into Facebook or explicitly logged out of your application so it doesn’t attempt to connect to Facebook
    and thus, we don’t know if they’ve authenticated your application or
    not. (unknown)

We are dealing with #3 in this case. However, when I visit facebook, I find I am not logged out. But at the same time, I am not “explicitly logged out” (meaning FB.logout() is called) from my site. So why is it returning ‘unknown’?

One solution I found on google says to add cookies: true to FB.init() in order to enable 3rd party cookies, so I did so:

          FB.init({
            appId      : process.env.FB_APP_ID,
            cookie     : true,                             
            xfbml      : true, 
            version    : 'v2.2'
          });

But this doesn’t change anything.

So why does FB.getLoginStatus() return ‘unknown’ for the response status when I open the site in a new tab?

Thanks.

asked 4 hours ago
gib65gib65

4042 silver badges13 bronze badges

Latest posts