I've added support for GoogleLogin to httplib2[1], it currentlly lives in svn and will be available in the next release.
In the process of implementing GoogleLogin I came across two things that could be changed to make the authentication system better. First, attempting an unauthorized operation results in a 401 response, which is excellent, and it includes a WWW-Authenticate header: WWW-Authenticate: GoogleLogin realm="https://www.google.com/accounts" There are two changes that would make that better. First, the URI you have to POST to to authenticate is actually https://www.google.com/accounts/ClientLogin and that's what should be returned in the realm. Secondly, a 'service' parameter is needed when you login and that could also be returned in the WWW-Authenticate: header. So if we tried an operation on the calendar service without authentication it should respond with: WWW-Authenticate: GoogleLogin realm="https://www.google.com/accounts/ClientLogin", service="cl" Where 'cl' is the value for the calendar service. This gives me all the information I need to automatically turn around and log the client in for calendar service or other services as they become available. You can get the latest httplib2 fresh from svn with: svn co https://svn.sourceforge.net/svnroot/httplib2/trunk httplib2 This makes is easier to work the calendar api, here is short example script creating and deleting an event: import httplib2 import cElementTree h = httplib2.Http() h.follow_all_redirects = True name, passwd = file("/home/jcgregorio/gmail", "r").read().split() h.add_credentials(name, passwd) body = """<entry xmlns="http://www.w3.org/2005/Atom"> ...blah... </entry>""" headers = {'Content-Type': 'application/atom+xml'} uri = "http://www.google.com/calendar/feeds/default/private/full" # Create a new entry in the calendar resp, content = h.request(uri, "POST", body=body, headers=headers) assert resp.status == 201 # Parse the response to find the Member URI ATOM = "http://www.w3.org/2005/Atom" ATOM_LINK = "{%s}link" % ATOM tree = cElementTree.fromstring(content) reledit = [l.get('href', '') for l in tree.findall(ATOM_LINK) if l.get('rel', '') == 'edit'] # Delete the newly created event resp, content = h.request(reledit[0], "DELETE") assert resp.status == 200 Thanks, -joe [1] http://bitworking.org/projects/httplib2/ -- Joe Gregorio http://bitworking.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Calendar Data API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/google-calendar-help-dataapi -~----------~----~----~----~------~----~------~--~---
