Skip to content

Instantly share code, notes, and snippets.

@xqms
Created August 26, 2010 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xqms/551027 to your computer and use it in GitHub Desktop.
Save xqms/551027 to your computer and use it in GitHub Desktop.
Generate a google session token for google calendar
"""
Get a google AuthSub token for google calendar
Usage: just run and follow the instructions.
Author: Max Schwarz <Max@x-quadraht.de>
"""
import gdata
import gdata.calendar.service
import gdata.service
import gdata.calendar
import sys
from optparse import OptionParser
if __name__ == "__main__":
parser = OptionParser()
parser.add_option("--google-single-token", dest="token", help="Google Data API token")
options, args = parser.parse_args()
calendar_service = gdata.calendar.service.CalendarService()
calendar_service.ssl = True
if not options.token:
next = 'http://hoffentlichnichtda.de'
scope = 'https://www.google.com/calendar/feeds/'
secure = False
session = True
print "Go to:", calendar_service.GenerateAuthSubURL(next, scope, secure, session)
print "And set the returned token using --google-single-token"
exit(0)
options.token = options.token.replace("%2F", "/")
calendar_service.SetAuthSubToken(options.token)
calendar_service.UpgradeToSessionToken()
print "Your session token is:", str(calendar_service.GetAuthSubToken())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment