我正试图通过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;虽然我没有太多使用这些模块,但我似乎没有遇到任何其他问题。有人知道怎么回事吗?
我今天遇到这个问题,必须从oauth2client版本2.0回滚到版本1.5.2,其中:
好像你还没有安装pyopenssl。通过
easy_install pyopenssl
安装。最近更新了source repository以使用新代码:
相关问题 更多 >
编程相关推荐