【发布时间】:2012-12-13 08:12:20
【问题描述】:
我正在尝试使用此代码通过 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;我似乎对这些模块没有任何其他问题,尽管我没有太多使用它们。有谁知道发生了什么?
【问题讨论】:
-
听起来像是第一次 google 发现错误:code.google.com/p/google-api-python-client/issues/detail?id=133
-
是的,但他们的 AppAssertion 解决方案并不理想——想知道 StackOverflow 人是否有其他方法。
标签: python google-api oauth-2.0