我正在尝试通过Python客户端使用此代码访问谷歌应用程序以获得授权(私人信息显然已编辑):
import gflags
import httplib2
from apiclient.discovery import build
from oauth2client.file import Storage
from oauth2client.client import SignedJwtAssertionCredentials
from oauth2client.tools import run
f = open('privatekey.p12', 'rb')
key = f.read()
f.close()
credentials = SignedJwtAssertionCredentials(
service_account_name='name@developer.gserviceaccount.com',
private_key=key,
scope = 'https://www.googleapis.com/auth/calendar')
http = httplib2.Http()
http = credentials.authorize(http)
service = build(serviceName='calendar', version='v3', http=http)
Run Code Online (Sandbox Code Playgroud)
但是我收到了这个错误:
ImportError: cannot import name SignedJwtAssertionCredentials
Run Code Online (Sandbox Code Playgroud)
我安装了Google v3 API Python客户端以及OAuth2; 我似乎没有对这些模块有任何其他问题,尽管我没有太多使用它们.有谁知道发生了什么?
我正在尝试在GAE Python中实现Google Identity Toolkit(gitkitv3).用户登录网站后,我收到以下错误:
'PKCS12 format is not supported by the PyCrpto library. '
NotImplementedError: PKCS12 format is not supported by the PyCrpto library. Try converting to a "PEM" (openssl pkcs12 -in xxxxx.p12 -nodes -nocerts > privatekey.pem) or using PyOpenSSL if native code is an option.
Run Code Online (Sandbox Code Playgroud)
基于SO回复,我在x.p12文件上运行以下命令,并使用生成的privatekey.pem文件:
openssl pkcs12 -passin pass:notasecret -in x.p12 -nocerts -passout pass:notasecret -out key.pem
openssl pkcs8 -nocrypt -in key.pem -passin pass:notasecret -topk8 -out privatekey.pem
Run Code Online (Sandbox Code Playgroud)
现在,我收到以下错误:
'X509 certs are not supported by the PyCrypto library. …Run Code Online (Sandbox Code Playgroud) google-app-engine pycrypto oauth-2.0 oauth2client google-oauth