For anyone who may read this and have the same problem. The tutorial
section indicates that google.accounts.user.login() can be run
immediately after loading, and it may be confusing to a user that is
directed to a google login page without seeing your page first. It
says that it is not recommended, and that a login button is the
preferred way to do it for real-world applications. It does not say
that your application will not work if google.accounts.user.login() is
called immediately after loading, and that you must provide a login
link/button. If you don't you will get a neverending loop at the grant/
deny access page. It seems that this is due to the cookie (containing
the token) not being stored quickly enough after redirection back to
your application page when login is called immediately after page
load.

Maybe this is something I should have seen or maybe the tutorial
shouldn't indicate that doing everything on page load is a viable
option.

On May 25, 12:21 pm, noGGin <lawrenc...@gmail.com> wrote:
> Yes, all of the interactive samples work for me. But if I insert that
> code into my initializePage function I still get the looping behavior.
> I checked the cookies after running the interactive examples, there is
> one named "g314-scope-0" and one named "g314-pending", whenever I run
> my own code I only get a cookie named "g314-pending".
>
> On May 25, 11:58 am, Eric Bidelman <api.e...@google.com> wrote:
>
> > Can you run this 
> > sample?http://code.google.com/apis/blogger/docs/1.0/developers_guide_js.html...
>
> > On Mon, May 25, 2009 at 11:29 AM, noGGin <lawrenc...@gmail.com> wrote:
>
> > > Here is my code pulled from my test page:
>
> > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
> > >www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> > > <html xmlns="http://www.w3.org/1999/xhtml";>
> > >  <head>
> > >    <meta http-equiv="content-type" content="text/html; charset=utf-8"/
>
> > >    <title>My Google Data API Application</title>
> > >    <script src="http://www.google.com/jsapi?
> > > key=ABQIAAAAMckdzp79H9T72-3yHiv-
> > > BRQBnJMNXV2JFGJdzYopxFXhdLLc0RRJkNyWywXhm8h-gZVIaxK4uLg69Q" type="text/
> > > javascript"></script>
> > >    <script type="text/javascript">
> > >    //<![CDATA[
>
> > >    google.load("gdata", "1.x");
> > >    google.setOnLoadCallback(initializePage);
>
> > >    function initializePage() {
> > >       var scope = "http://www.blogger.com/feeds/";;
> > >       if (google.accounts.user.checkLogin(scope)) {
> > >          var service = new google.gdata.BloggerService('lawrence79-
> > > TestApp-v1.0');
> > >         alert("here");
> > >      } else {
> > >          var token = google.accounts.user.login(scope);
> > >      }
> > >    }
>
> > >     //]]>
> > >    </script>
> > >  </head>
> > >  <body>
> > >    <div id="panel"/>
> > >  </body>
> > > </html>
>
> > > I tried to display a simple alert after login but I get the
> > > neverending access request loop. I am not blocking cookies. I've also
> > > tried with and without the api key on my domain. I've also tried it on
> > > my localhost. I'm not sure what I'm doing wrong.
>
> > > On May 25, 11:04 am, Eric Bidelman <api.e...@google.com> wrote:
> > > > Hi guys,
> > > > Try setting up your page as follows:
> > >http://gdatatips.blogspot.com/2008/12/using-javascript-client-library...
>
> > > > Basically, you need a flow like this:
> > > > google.load('gdata', '1.x');google.setOnLoadCallback(initializePage);
>
> > > > function initializePage() {
> > > >    var scope = 'http://www.google.com/m8/feeds/';
> > > >    if (google.accounts.user.checkLogin(scope)) {
> > > >      var service = new
> > > google.gdata.contacts.ContactsService('co-App-v1.0');
> > > >      // get data
> > > >    } else {
> > > >      // redirect to Google to get a token
> > > >      var token = google.accounts.user.login(scope); // can ignore the
> > > > returned token value
> > > >    }
>
> > > > }
>
> > > > <http://gdatatips.blogspot.com/2008/12/using-javascript-client-library..
> > > .>
> > > > Eric
>
> > > > On Mon, May 25, 2009 at 10:53 AM, noGGin <lawrenc...@gmail.com> wrote:
>
> > > > > I am experiencing the same functionality. Has anyone found a
> > > > > resolution?
>
> > > > > On May 10, 10:19 am, Haberkornelius <marc.haberk...@gmail.com> wrote:
> > > > > > My application is attempting to read a list of Contacts using the
> > > > > > Contacts API.  I am using the JavaScript client library at
> > > google.com/
> > > > > > jsapi.  I invoke:
>
> > > > > > function logMeIn() {
> > > > > >       var scope = 'http://www.google.com/m8/feeds';
> > > > > >       var token = google.accounts.user.checkLogin(scope);
> > > > > >       alert('token is: ' + token);
> > > > > >       token = google.accounts.user.login(scope);
>
> > > > > > }
>
> > > > > > This asks me first, which Google Account would I like to use (I have
> > > > > > 2), then asks me whether to accept or deny the access request.  I
> > > > > > accept, and my browser is directed back to my page at:
>
> > > > > >http://localhost:8000/contacts_google#2%2FT7Zr-SI3SYU6R_HJSHd8gA
>
> > > > > > The logMeIn() function executes again, and the output is "token is:
> > > > > > " (empty string).  Then, the page is forwarded back to Google to ask
> > > > > > me which account to use, etc....it loops forever.  It seems like the
> > > > > > JS client library is not correctly parsing the token from the URI.
> > > > > > I've looked at the cookies defined for localhost, and I see one
> > > called
> > > > > > g314-pending.
>
> > > > > > I'm currently running an application in a test environment on my
> > > > > > desktop (URL ishttp://localhost:8000), but I'm not thinking that
> > > > > > should pose a problem, unless the JS client library is hardcoded to
> > > > > > NOT support localhost.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Data Protocol" group.
To post to this group, send email to google-help-dataapi@googlegroups.com
To unsubscribe from this group, send email to 
google-help-dataapi+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to