Wednesday, October 11, 2006

A Step Closer to Google Authentication?

Thanks to a comment left by Frank Mantek regarding the issue I was having with my Blogger-beta authentication, I've been able to get a step closer (I think?) to success. Frank was correct in his assumption that I was getting a 302 redirect response from the ClientLogin URL, and that my custom headers weren't being resent to the new URL. The response I got was a dictionary which contained of course the status code of 302, and also a location key with a value of http://beta.blogger.com/feeds/BLOGID/posts/full. Being quite new to all of this HTTP stuff, I can only assume that location is where the redirect was pointing to. I then implemented a test on the return status code, if it is 302, I manually resent the post and custom headers to the new location, and got a new error!

The new error is a 400 Bad Request error, and the content says GoogleLogin auth token is malformed. A search online for that error string revealed a guy with the same problem, but no responses. Since that thread was too old to reply to and revive, I had to start a new and similar thread. Hopefully it'll get some action.

I won't post all of the new code as most of it remains unchanged. I simply modified the getPost() function to take the URL to make the request to. The new stuff looks like this, with the test for redirect included:

h = httplib2.Http()
uri = 'http://www.blogger.com/feeds/BLOGID/posts/full'

cert = authenticate()
if cert:
    response, content = postEntry(cert, uri)
    while response['status'] == '302':
        cert = authenticate()
        response, content = postEntry(cert, response['location'])
    print response, content

Hopefully this is in fact a step closer. I'd love to get this working. Thanks for the comment and the help, Frank! :)

No comments:

Post a Comment