Skip to content

Instantly share code, notes, and snippets.

@potomak
Created November 27, 2013 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save potomak/7680333 to your computer and use it in GitHub Desktop.
Save potomak/7680333 to your computer and use it in GitHub Desktop.
FB.getLoginStatus Chromium error
FB.getLoginStatus Object {authResponse: undefined, status: "unknown"}
FB.login Object {authResponse: Object, status: "connected"}
FB.getLoginStatus Object {authResponse: Object, status: "connected"}
<html>
<head>
<title>FB.getLoginStatus test</title>
</head>
<body>
<h1>FB.getLoginStatus test</h1>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId : 'YOUR_APP_ID', // App ID from the app dashboard
status : true, // Check Facebook Login status
xfbml : true // Look for social plugins on the page
});
// Additional initialization code such as adding Event Listeners goes here
FB.getLoginStatus(function(response) {
console.log('FB.getLoginStatus', response);
if (response.status === 'connected') {
// the user is logged in and has authenticated your
// app, and response.authResponse supplies
// the user's ID, a valid access token, a signed
// request, and the time the access token
// and signed request each expire
var uid = response.authResponse.userID;
var accessToken = response.authResponse.accessToken;
} else if (response.status === 'not_authorized') {
// the user is logged in to Facebook,
// but has not authenticated your app
} else {
// the user isn't logged in to Facebook.
FB.login(function(response) { console.log('FB.login', response); });
}
});
};
// Load the SDK asynchronously
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
</body>
</html>
FB.getLoginStatus Object {authResponse: undefined, status: "unknown"}
FB.login Object {authResponse: Object, status: "connected"}
@Jyrno42
Copy link

Jyrno42 commented Dec 17, 2013

Same happens here, have you submitted this to the bugtracker for Facebook?

@filipstachura
Copy link

I've faced the same problem. Have you reported that issue?

@omarloren
Copy link

Is this solved somehow?, same problem here :(

@marianosimone
Copy link

Check if you have "3rd party cookies" enabled on your browser (SO thread)

@pavan9095
Copy link

FB.getLoginStatus Object {authResponse: undefined, status: "unknown"}
FB.login Object {authResponse: Object, status: "connected"}

In chrome browser.

@jerodb
Copy link

jerodb commented Jun 3, 2016

I had the same problem for Chromium (I think is the same in Chrome) and found the answer here: Stackoverflow Q&A

Chromium is configured to block third-party cookies and data.
This fixed it for my browser:

  1. Go to Chrome Settings.
  2. Show advanced settings...
  3. Privacy...
  4. Content settings...
  5. uncheck Block third-party cookies and site data.

So, be careful if you use FB.getLoginStatus in production. Chrome users might find some problems here.

@gauravuber
Copy link

@jerodb unchecked Block third-party cookies and site data still not working.

@matte0080
Copy link

Still problem too in 2023 :( Somebody have news about it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment