ImportError:无法导入名称SignedJwtAssertionCredentials - python

我正在尝试使用以下代码通过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='[email protected]',
    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;尽管这些模块并没有太多使用,但似乎没有任何其他问题。有人知道发生了什么吗?

参考方案

似乎您尚未安装pyopenssl。通过easy_install pyopenssl安装。

Libraries oauth2client.client
if HAS_OPENSSL:
  # PyOpenSSL is not a prerequisite for oauth2client, so if it is missing then
  # don't create the SignedJwtAssertionCredentials or the verify_id_token()
  # method.

  class SignedJwtAssertionCredentials(AssertionCredentials):
....

ImportError:没有名为“ ldap”的模块Python 3.5 - python

我正在运行Python 3.5(在Windows上),并且已经从https://pypi.python.org/pypi/python-ldap/安装了python-ldap我也尝试使用ldap3,但我一直收到错误消息"ImportError: No module named 'ldap'我环顾四周,看到有人说3.5没有pyth…

通过Python使用FacePlusPlus API - python

我收到以下错误。'error_message': 'BAD_ARGUMENTS 当我执行此python代码时。import requests import json response = requests.post( 'https://api-us.faceplusplus.com/facepp/v3/detect&#…

在返回'Response'(Python)中传递多个参数 - python

我在Angular工作,正在使用Http请求和响应。是否可以在“响应”中发送多个参数。角度文件:this.http.get("api/agent/applicationaware").subscribe((data:any)... python文件:def get(request): ... return Response(seriali…

Python-使用请求时发布请求失败 - python

使用外壳程序时,我可以通过运行以下命令成功创建新用户curl --user administrator:pasword "Content-Type: application/json" https://localhost:8080/midpoint/ws/rest/users -d @user.json但是,当我尝试使用请求在python…

Python exchangelib在子文件夹中读取邮件 - python

我想从Outlook邮箱的子文件夹中读取邮件。Inbox ├──myfolder 我可以使用account.inbox.all()阅读收件箱,但我想阅读myfolder中的邮件我尝试了此页面folder部分中的内容,但无法正确完成https://pypi.python.org/pypi/exchangelib/ 参考方案 您需要首先掌握Folder的myfo…