Skip to content

Instantly share code, notes, and snippets.

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 onyxfish/619313 to your computer and use it in GitHub Desktop.
Save onyxfish/619313 to your computer and use it in GitHub Desktop.
How to fetch Google Spreadsheets from AppEngine
def fetch_csv(self, options):
"""
Retrieves a single Google spreadsheet as CSV using ClientLogin
authentication.
TODO: handle retries and timeouts on auth calls
TOOD: handle retries and timeouts on content fetching
"""
client = gdata.docs.client.DocsClient()
client.ClientLogin(config.USER_EMAIL, config.USER_PASSWORD, config.APP_DOMAIN)
spreadsheets_client = gdata.spreadsheet.service.SpreadsheetsService()
spreadsheets_client.ClientLogin(config.USER_EMAIL, config.USER_PASSWORD, config.APP_DOMAIN)
docs_token = client.auth_token
client.auth_token = gdata.gauth.ClientLoginToken(spreadsheets_client.GetClientLoginToken())
return client.get_file_content(CSV_URL % options)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment