Using gspread with OAuth2 SignedJwtAssertionCredentials
I am trying to access my google spreadsheet using oauth2 using gspread Python Library. I am new to Oauth2 and understand its benefits. But I cannot use it. Far away I visited https://code.google.com/apis/console/ and generated client id, SECRET and REDIRECT URI.
credentials = SignedJwtAssertionCredentials('developer@example.com', SIGNED_KEY, scope)
According to the Gspread Docs I will need a SIGNED_KEY object. How can I get it?
An example will be very helpful.
source to share
In the developer console ( https://console.developers.google.com go to API and log in> Credentials and click "Create new client ID" then select "Service Account", your browser should download the .p12 file. Now convert its in PEM for GAE by executing this on the command line:
openssl pkcs12 -passin pass:notasecret -in privatekey.p12 -nocerts -passout pass:notasecret -out key.pem
openssl pkcs8 -nocrypt -in key.pem -passin pass:notasecret -topk8 -out privatekey.pem
Then you need to move the PEM to your application directory, open it in your application code and then use it as the second arg in SignedJwtAssertionCredentials
Also make sure the libraries section app.yaml
includespycrypto
libraries:
- name: pycrypto
version: "2.6"
I got this from someone very helpful tutorial
source to share