#!/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()

