5 messages in com.googlegroups.google-calendar-help-dataapiRe: 401 Authorization required proble...
FromSent OnAttachments
Adam20 Jul 2006 13:04 
Frank Mantek21 Jul 2006 02:29 
Adam Medcalf21 Jul 2006 09:41 
Frank Mantek21 Jul 2006 11:10 
Adam Medcalf21 Jul 2006 12:49 
Subject:Re: 401 Authorization required problem the first time I try to add event
From:Frank Mantek (fman@gmail.com)
Date:07/21/2006 02:29:40 AM
List:com.googlegroups.google-calendar-help-dataapi

What i am suspecting is that sharding might get in the way...

Google servers will, normally on your first login, or periodically pending load, redirect your attempt to get to your data to the correct server for you. This is called sharding, and it results in a 302 return code.

Now, pending on how you setup your connection, that 302 handling happens underneath you - but you have to handle this yourself. If it happens automatically (like wininet handles it), what happens is:

- you send your auth header to server A - server A returns a 302 - wininet connects to Server B, but does not send the authheader - you get a 401 back...

You need to handle the 302 and then your good to go.

On 7/20/06, Adam <adam@googlemail.com> wrote:

Hi,

I have just started experimenting with adding events to the Google Calendar from Visual Studio 6. As I am using VB6 to test I am manually sending Google the requisite XML to create events in the following manner:

1) POST login details to https://www.google.com/accounts/ClientLogin 2) Parse the auth code from Google's response 3) POST the XML event details to http://www.google.com/calendar/feeds/default/private/full including the requisite Authorization (and code) and Content-Type.

The strange thing is that most of the time this works fine, response codes are what you would expect, and the event is added to the Google calendar.

However, if it is the first time I run the application, at step 3, instead of the 201 Created response I should get, I get:

HTTP/1.1 401 Authorization required WWW-Authenticate: GoogleLogin realm="https://www.google.com/accounts" Cache-control: private Content-Length: 167 Date: <whatever> Content-Type: text/html Server: GFE/1.3

If I then go on to repeat the process right away without quitting my test app, get a new auth code, send the event, it is added as normal for as many times as I want to. If however I exit the program, start it again, then again the first time I will always get the 401 response.

Could anyone throw some light on this? I can't understand why if I sent the same commands that gave me a 401 a second time it works, but the first time I always get a 401? Being an extreme novice, it's almost like the first Auth token google gives me when I load my test program is invalid. The same code works with the 2nd one though. I have checked that the Auth code is definitely getting passed to the server every time.

If I can give any more useful info just let me know.

Many thanks,