title: Login to facebook with android, phonegap, childBrowser
body: <p>I managed to log into Facebook with childBrowser plugin without any problems:</p>
  
  <pre><code>function deviceStart() {
  
     FB.init({ appId: "xxxxxxxxxxxxxx", nativeInterface: PG.FB });
  
  };
  
  function onPubFacebookBtn(){ // I call this from a button
  var my_client_id  = "xxxxxxxxxxxxx",
  my_redirect_uri   = "http://www.facebook.com/connect/login_success.html",
  my_type           = "user_agent",
  my_display        = "touch"
  
  var authorize_url  = "https://graph.facebook.com/oauth/authorize?";
  authorize_url += "client_id="+my_client_id;
  authorize_url += "&amp;redirect_uri="+my_redirect_uri;
  authorize_url += "&amp;display="+my_display;
  authorize_url += "&amp;scope=publish_stream,user_photos,email,user_online_presence,offline_access"
  
  window.plugins.childBrowser.onLocationChange = facebookLocChanged;
  window.plugins.childBrowser.onClose = closed;
  window.plugins.childBrowser.showWebPage(authorize_url);
  
  }
  
  function facebookLocChanged(loc){
  
  if (/login_success/.test(loc)) { 
     var fbCode = loc.match(/code=(.*)$/)[1]
  
     localStorage.setItem('pg_fb_session', JSON.stringify(fbCode));
  
     FB.Auth.setSession(fbCode, 'connected');
     window.plugins.childBrowser.close();
  }}
  </code></pre>
  
  <p>When I test if the app is logged in with</p>
  
  <pre><code>function getLoginStatus() {
  FB.getLoginStatus(function(response) {
   if (response.session) {
       alert('logged in');
   } else {
     alert('not logged in');
  }
  });
  }
  </code></pre>
  
  <p>it returns "loged in", but when I try to get user ID i get an error saying I need an active access token:</p>
  
  <pre><code>function me() {
  FB.api('/me', function(response) {
      if (response.error) {
          alert(JSON.stringify(response.error));
       } else {
           var data = document.getElementById('data');
            response.data.forEach(function(item) {
             var d = document.createElement('div');
             d.innerHTML = item.name;
             data.appendChild(d);
         });
         }
  });
  }
  </code></pre>
  
  <p>This is a mixture of 2 solutions for loging into facebook of which none works.
  Help!?</p>