Google Login Script Example

I've been playing with Google's Account Authentication API. This was released with the Google Data API. The Calendar API, based on Google Data, seems to have gained some traction, at least in terms of people writing about it. But it's the authentication stuff that grabs my interest (not that GData isn't cool).

I've worked up a little Python script that will get an auth token, given a Google account name and password.

#!/usr/bin/env python
# Google Account Login Script

import urllib
import re

# Replace these variables, or pass them as args to the script
USER = 'YOUR_GOOGLE_USER_NAME'
PASSWD = 'YOUR_PASSWD'
APP = 'COMPANY-APPNAME-VERSION'

AUTHURL = 'https://www.google.com/accounts/ClientLogin'

# Only known service is calendar at this point
SERVICE = 'cl'

# Build POST query string, and regxep the returned token
query = 'Email=' + USER + '@gmail.com&Passwd=' + \
    PASSWD + '&service=' + SERVICE + '&source=' + APP
response = urllib.urlopen(AUTHURL, query).read()
token = re.search('Auth=(.*)', response).groups()

The script is available if anyone would find it useful to have an example.

This only works with the Calendar service as far as I know. Has anyone heard of any other Google services that will allow use of the authentication API?

Posted by deryck on June 2, 2006

Post a comment

Comments temporarily closed.