Search code examples
pythonauthenticationgoogle-docsgdatagoogle-docs-api

How to use a auth token from Docservice on a spreadsheetservice object


I am initially loggin into a google account using the gdata.docs.service.Docservice

At some point, I would like to manipulate a spreadsheet using the gdata.spreadsheet.service.SpreadsheetsService

I don't want to have to re-login with the new spreadsheet object, so how do I pass authentication over to the newly created spreadsheet object?

client = gdata.docs.service.DocsService()
client.ClientLogin(username, password)

ssclient = gdata.spreadsheet.service.SpreadsheetsService()

Solution

  • When you request a token using ClientLogin, the service class appends an extra query param called service= to your POST request. Each service is uniquely identified.

    • Docs: service=writely
    • Spreadsheet: service=wise

    The Auth token you receive is should be valid for only that particular service.

    That aside, you should move to OAuth. ClientLogin i.e, username/password is highly discouraged.