aseps3472 / gdata-javascript-client

Automatically exported from code.google.com/p/gdata-javascript-client
0 stars 0 forks source link

Authorization fails after dynamic (lazy) api load #5

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
the authorization can't be established, when dynamically loading the gdata 
libraries:
    var gscope = "http://www.blogger.com/feeds"; 
    var service; 
    function onGDataLoaded(){ 
      var loggedIn = !!google.accounts.user.checkLogin(gscope); 
      $('#gdata-status').text(loggedIn); 
      if (loggedIn) { 
        service = new google.gdata.blogger.BloggerService('de.petrikas.app'); 
      }else{ 
        google.accounts.user.login(gscope); 
      } 
    } 

    $('#load-gdata').click(function(){ 
      google.load("gdata", "1.x", { 
        callback : onGDataLoaded 
      }); 
    }); 

fulll code here:
 http://petrikas.de/files/gdata-test.html 

the google.accounts.user.checkLogin(gscope) status will be always 
empty string , no matter how many times I authorize the site. 

Original issue reported on code.google.com by Matas.Pe...@gmail.com on 22 Jul 2009 at 8:17

GoogleCodeExporter commented 8 years ago
I have exactly the same problem. It makes the API useless.

Original comment by colinab...@gmail.com on 18 Sep 2009 at 3:53

GoogleCodeExporter commented 8 years ago
When using google.load with a callback you may have to invoke 
google.gdata.onLoad()
from your callback, before anything else, in order to allow AuthSub to complete.

Also, from my experience, the actual login status may not be available 
immediately
after GData is loaded, since it first has to consume the AuthSub token in the 
URL
before setting the status to LOGGED_IN from LOGGING_IN.

Original comment by bobbysoa...@gmail.com on 15 Nov 2009 at 1:30

GoogleCodeExporter commented 8 years ago
thanks bobby!
at last, based on your insight, I was able to lazy load the gdata and 
authorize. I've written a wrapper function for 
this, if anybody needs to lazyload gdata, you can find it here:
http://gist.github.com/236842

still, I think google team could build a native callback for this kind of flow.

Original comment by Matas.Pe...@gmail.com on 17 Nov 2009 at 11:19