gpt4 book ai didi

python - 导入错误 : cannot import name SignedJwtAssertionCredentials

转载 作者:IT老高 更新时间:2023-10-28 22:01:22 26 4
gpt4 key购买 nike

我正在尝试使用此代码通过 Python 客户端访问 google 应用程序以获得授权(显然已编辑私有(private)信息):

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 版:

pip install oauth2client==1.5.2

关于python - 导入错误 : cannot import name SignedJwtAssertionCredentials,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14063124/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com