Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FB.getLoginStatus doesn't fire if the user is not logged in to Facebook

I am working on a Facebook application which is integrated with Facebook and am trying to get the user's FB session. As far as I understand, a common usage scenario is as follows.

  1. call FB.init()
  2. call FB.getLoginStatus giving it an appropriate callback.

I ran the following code (the application id).

<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript">
    <!--

    function init(){
        FB.init({
            appId  : '9999999999999',
            status : true, // check login status
            cookie : true, // enable cookies to allow the server to access the session
            xfbml  : true, // parse XFBML
            channelUrl : 'http://127.0.0.1:8888/channel.html', // custom channel
            oauth  : true // enable OAuth
        });
        alert('going to call FB.getLoginStatus ');

        FB.getLoginStatus(function(response) {
            alert('whoo hoo!!! getLoginStatus called the callback');
        });
    }
    init();
    //-->
</script>

If the user is already logged in to Facebook in the same browser session then everything works as expected - returning the populated _response.authResponse_. However, if the user is not logged in to Facebook the callback is not triggered at all. Checking the browsers network log, I see that Facebook returns the following response (request from http://www.facebook.com/dialog/oauth?).

Application Error: There was a problem getting data for the application you requested. The application may not be valid, or there may be a temporary glitch. Please try again later.

I checked this on Chrome and Firefox (Mac).


Update

I would like to thank everyone who responded.

Ben's comment had the answer.

Thanks Ben - you saved me lots of frustration.

like image 220
Nitzan Volman Avatar asked Aug 29 '11 12:08

Nitzan Volman


1 Answers

The cause is a recent bug which only affects sandbox mode. I switched off sandbox mode, and it worked like a charm.

like image 105
Nitzan Volman Avatar answered Oct 31 '22 13:10

Nitzan Volman