title: Facebook FB.login dialog fails with error
body: <pre><code>New to Facebook apps, developing a test app using JavaScript:
  </code></pre>
  
  <ol>
  <li><p>I am logged-in to Facebook as the app administrator (regular user).</p></li>
  <li><p>I get to the point where FB.getLoginStatus returns response.status === 'not_authorized'.</p>
  
  <ol>
  <li>I call FB.login.</li>
  <li><p>I get a popup saying "An error occurred. Please try again later."</p></li>
  <li><p>FB.login calls back with response.authResponse = null.</p></li>
  <li><p>The console log says "LOG: Could not find callback 1".</p></li>
  </ol></li>
  </ol>
  
  <p>I get the same error in all browsers...
      Help?</p>
  
  <pre><code>Here is the relevant code - I replaced actual strings by ######:
  
  &lt;div id="fb-root"&gt;&lt;/div&gt;
  
  &lt;script&gt;
  
  var init_status = 1;
  var login_status = 1;
  var signedRequest = ' ';
  
  window.fbAsyncInit = function() {
    FB.init({
      appId      : '######', // App ID from the App Dashboard
      channelUrl : 'http://#####/channel.php', // Channel File for x-domain communication
      status     : true, // check the login status upon init?
      cookie     : true, // set sessions cookies to allow your server to access the session?
      xfbml      : false  // parse XFBML tags on this page?
    });
    getLoginStatus();
  };
  
  // Load the SDK Asynchronously:
  (function(d){
    var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
    if (d.getElementById(id)) {return;}
    js = d.createElement('script'); js.id = id; js.async = true;
    js.src = "//connect.facebook.net/en_US/all.js";
    ref.parentNode.insertBefore(js, ref);
  }(document));
  
  call_proceed1_when_ready(); // wait for init_status &gt; 1
  
  function proceed1() {
  
    // Login the user and/or authenticate with app, if necessary:
    if (init_status &gt; 2) {
      login ();
    } else {
      login_status = 2;
    }
  
    call_proceed2_when_ready(); // wait for login_status &gt; 1
  
  } //proceed1
  
  function proceed2() {
  
    alert('DONE');
  
  } //proceed2
  
  ////////////////
  // FUNCTIONS: //
  ////////////////
  
  function call_proceed1_when_ready () {
    if (init_status &gt; 1) {
      proceed1();
    } else {
      setTimeout(call_proceed1_when_ready, 500); // 0.5 second
    }
  }
  
  function call_proceed2_when_ready () {
    if (login_status &gt; 1) {
      proceed2();
    } else {
      setTimeout(call_proceed2_when_ready, 500); // 0.5 second
    }
  }
  
  function getLoginStatus() {
    FB.getLoginStatus(function(response) {
      if (response.status === 'connected') {
        signedRequest = response.authResponse.signedRequest;
        init_status = 2;
      } else if (response.status === 'not_authorized') {
        init_status = 3;
      } else {
        init_status = 4;
      }
    });
  }
  
  function login() {
    FB.login(function(response) {
      if (response.authResponse) {
        login_status = 2;
      } else {
        login_status = 3;
      }
    });
  }
  
  &lt;/script&gt;
  </code></pre>