Please confirm: SignedJwtAssertionCredentials only work with SpreadsheetsClient tables, not service tables?

After a week of Google and trial and error, I finally got my Python script that adds a row to a Google spreadsheet to work with OAuth2. For the benefit of others who may be suffering from the same trauma, here's my working code:

script_dir  = os.path.dirname(os.path.realpath (sys.argv[0]))
private_key = open(script_dir + "\\myClient.pem").read()
ssClient    = gdata.spreadsheets.client.SpreadsheetsClient()

credentials = SignedJwtAssertionCredentials(CLIENT_EMAIL, private_key, SCOPE)
http        = Http()
http        = credentials.authorize(http)
auth2token  = gdata.gauth.OAuth2TokenFromCredentials(credentials)
ssClient    = auth2token.authorize(ssClient)

ssClient.GetSpreadsheets()

      

Two notes:

  • This does NOT work if I use gdata.spreadsheet.service.SpreadsheetsService()

    , but does work withgdata.spreadsheets.client.SpreadsheetsClient()

  • This does NOT work with .p12 files downloaded from google developer console, I needed to convert it to a .pem file using

    openssl pkcs12 -nodes -nocerts -in myClient.p12 -out myClient.pem
    
          

Can someone please confirm that there is no way to use SignedJwtAssertionCredentials

with SpreadsheetsService

, or if there is, please explain the correct procedure? I've pretty much tried every combination I could think of.

Thank!

+3


source to share


1 answer


I feel your pain, spent all day trying to get my old gdata.spreadsheet.service code to work with oauth2client.client.SignedJwtAssertionCredentials and still haven't been able to get it to work. This doesn't work for me with SpreadsheetsClient or SpreadsheetsService, nor when converting .p12 to .pem. It looks like it works (no auth error messages), but when you do for example a call to GetSpreadsheets (), I get an empty result.



Couldn't find good examples of connecting old gdata code to oauth, your snippet above was the clearest one to find so far. The fight continues.

0


source







All Articles