我正在尝试使用此代码通过 Python 客户端访问 google 应用程序以获得授权(显然已编辑私人信息):
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)
然而我收到这个错误:
ImportError: cannot import name SignedJwtAssertionCredentials
我已经安装了 Google v3 API Python 客户端以及 OAuth2;我似乎对这些模块没有任何其他问题,尽管我没有太多使用它们。有谁知道发生了什么?