[英]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. 我正在尝试使用gaz Python Library使用oauth2访问我的Google电子表格。我是Oauth2的新手,并了解它的好处。但我无法使用它。到目前为止,我访问过https://code.google.com/apis / console /和生成的CLIENT ID,SECRET和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? 根据Gspread Docs,我需要一个SIGNED_KEY对象。我怎么做到的?
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. 在开发人员控制台中,( https://console.developers.google.com )转到API&auth>凭据,然后单击“创建新客户端ID”,然后选择“服务帐户”。 Your browser should download a .p12 file.
您的浏览器应该下载.p12文件。 Now convert it to a PEM for GAE by doing this in the command line:
现在通过在命令行中执行此操作将其转换为GAE的PEM:
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
然后,您必须将PEM移动到您的应用程序目录,在您的应用程序代码中打开它,然后将其用作
SignedJwtAssertionCredentials
的第二个arg
Also make sure the app.yaml
libraries section includes pycrypto
还要确保
app.yaml
库部分包含pycrypto
libraries:
- name: pycrypto
version: "2.6"
I got this from someone's very helpful tutorial 我从某人的非常有用的教程中得到了这个
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.