简体   繁体   中英

Using gspread with OAuth2 SignedJwtAssertionCredentials

I am trying to access my google Spreadsheet using oauth2 using the gspread Python Library.I am new to Oauth2 and understand its benefits.But I am unable to use it.So far I have 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 do I get that?

An example will be very helpful.

In the developer console, ( https://console.developers.google.com ) go to APIs & auth > Credentials and click Create new Client ID, then choose Service Account. Your browser should download a .p12 file. Now convert it to a PEM for GAE by doing this in 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

You then have to move the PEM to your app directory, open it in your app code and then use it as the second arg in SignedJwtAssertionCredentials

Also make sure the app.yaml libraries section includes pycrypto

libraries:
- name: pycrypto
  version: "2.6"

I got this from someone's very helpful tutorial

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM