A problem with authorization after dynamic (lazy) api load

10 views
Skip to first unread message

matas

unread,
Jul 14, 2009, 11:30:59 AM7/14/09
to Google AJAX APIs
hi all,

I'm not sure if I've missed something, but I can't get authorized when
using dynamic api loading. The authorization page keeps popping up, no
matter how many times I've confirmed it.

the code example can be found here: http://petrikas.de/files/gdata-test.html

Static/inline gdata loading works without a problem, but in my case
I'd like to load the lib only when the user needs it.

does anybody had similar issues? or is dynamic loading incompatible
with jquery?

thanks in advance!

matas

unread,
Jul 17, 2009, 5:03:24 AM7/17/09
to Google AJAX APIs
sorry for repeating myself: but does anybody have a clue, why this
fails to establish an authorization:

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
});
});

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. should I
add some timeout maybe?

Jeff S (Google)

unread,
Jul 17, 2009, 3:21:10 PM7/17/09
to Google-AJAX...@googlegroups.com
Hi matas,

I don't think the issue is with the combination of jQuery and the Google Data Ajax library. I de-jQurified your code and saw the same login loop. I'm still trying to track down exactly where the problem is but in the meantime this simple-but-working sample should help. 


Thank you,

Jeff

Jeff S (Google)

unread,
Jul 17, 2009, 5:01:24 PM7/17/09
to Google-AJAX...@googlegroups.com
Hi matas,

Just to follow up, I was able to get your code to work if I moved the google.load call outside of the user triggered click event and just had it execute at page load. I think this should work if you do something like

<script type="text/javascript">
    google.load("gdata", "1.x", {
        callback : onGDataLoaded
      });
    function onGDataLoaded() {
      // if the user is not logged in, add a Sign In button to the page.
      // else proceed with new service object creation...
    }

Happy coding,

Jeff

wiwied yati

unread,
Jul 17, 2009, 5:27:29 PM7/17/09
to Google-AJAX...@googlegroups.com
Pease hel me my PC CD ATAPI LOST Because I 'm re install computter,
lastday Compt error.....

Please My PC Re Image BOsster How About me Re Download again, Idont
Understand.....Please u inform me.....? How about me must Network
Confrence if my PC CD ATAPI Lost .....?




2009/7/18 Jeff S (Google) <j...@google.com>:

matas

unread,
Jul 20, 2009, 4:38:01 AM7/20/09
to Google AJAX APIs
hi Jeff,

you solution is loading the libs on every site load, which is what I
wanted to avoid.
So I assume the dynamic loading doesn't work with authentication :(
is there any bugtracker for js APIs, where I could fill in the bug?

cheers,
Matas

On Jul 17, 11:01 pm, "Jeff S (Google)" <j...@google.com> wrote:
> Hi matas,
> Just to follow up, I was able to get your code to work if I moved the
> google.load call outside of the user triggered click event and just had it
> execute at page load. I think this should work if you do something like
>
> <script type="text/javascript">
>     google.load("gdata", "1.x", {
>         callback : onGDataLoaded
>       });
>     function onGDataLoaded() {
>       // if the user is not logged in, add a Sign In button to the page.
>       // else proceed with new service object creation...
>     }
>
> Happy coding,
>
> Jeff
>
> On Fri, Jul 17, 2009 at 12:21 PM, Jeff S (Google) <j...@google.com> wrote:
>
>
>
> > Hi matas,
> > I don't think the issue is with the combination of jQuery and the Google
> > Data Ajax library. I de-jQurified your code and saw the same login loop. I'm
> > still trying to track down exactly where the problem is but in the meantime
> > this simple-but-working sample should help.
>
> >http://ajax-apis.appspot.com/html/gdata-test.html
>
> > Thank you,
>
> > Jeff
>

Jeff S (Google)

unread,
Jul 20, 2009, 1:35:19 PM7/20/09
to Google-AJAX...@googlegroups.com
Hi matas,

The open source project for the gdata-javascript-client is here along with the issue tracker 

http://code.google.com/p/gdata-javascript-client/

I've also pinged one of the primary maintainers of the library about this issue.

Thank you,

Jeff

Jeff S (Google)

unread,
Jul 20, 2009, 7:17:57 PM7/20/09
to Google-AJAX...@googlegroups.com
Hello matas,

We were able to dicover a workaround. The gdata JavaScript library needs to have it's onLoad explicitly called in order to pick up the AuthSub token in the window's location. If you add the following call to your google.load callback, you should be able to obtain the token even after a dynamic load:

google.gdata.onLoad();

This would be the first line in your onGDataLoaded function.

Happy coding,

Jeff

matas

unread,
Jul 22, 2009, 4:25:40 AM7/22/09
to Google AJAX APIs
Hello Jeff,

thank you for your help. I've tried calling a google.gdata.onLoad
function in my callback, but it didn't work:
http://petrikas.de/files/gdata-test1.html

I've filled a bug report, hopefully it'll be solved in the next
library version.

Cheers,
Matas


On Jul 21, 1:17 am, "Jeff S (Google)" <j...@google.com> wrote:
> Hello matas,
>
> We were able to dicover a workaround. The gdata JavaScript library needs to
> have it's onLoad explicitly called in order to pick up the AuthSub token in
> the window's location. If you add the following call to your google.load
> callback, you should be able to obtain the token even after a dynamic load:
>
> google.gdata.onLoad();
>
> This would be the first line in your onGDataLoaded function.
>
> Happy coding,
>
> Jeff
>
> On Mon, Jul 20, 2009 at 10:35 AM, Jeff S (Google) <j...@google.com> wrote:
>
>
>
> > Hi matas,
>
> > The open source project for the gdata-javascript-client is here along with
> > the issue tracker
>
> >http://code.google.com/p/gdata-javascript-client/
> >http://code.google.com/p/gdata-javascript-client/issues/list
>
> > I've also pinged one of the primary maintainers of the library about this
> > issue.
>
> > Thank you,
>
> > Jeff
>
Reply all
Reply to author
Forward
0 new messages