gpt4 book ai didi

python - Dropbox Python SDK SSL 错误

转载 作者:太空宇宙 更新时间:2023-11-03 13:45:51 31 4
gpt4 key购买 nike

我正在学习如何使用 Dropbox Python SDK。但是,当我尝试生成请求 token 时遇到了问题。这是我正在使用的代码(请注意,我在这里用 APP_KEY 和 APP_SECRET 替换了我实际的应用程序 key 和 secret ,但我在尝试时使用了我实际的应用程序 key 和 secret 。)

from dropbox import client, rest, session
APP_KEY = 'APP_KEY'
APP_SECRET = 'APP_SECRET'
ACCESS_TYPE = 'app_folder'
print 'Creating session object'
sess = session.DropboxSession(APP_KEY, APP_SECRET, ACCESS_TYPE)
print 'Session created!\nCreating request token'
request_token = sess.obtain_request_token()
print 'Created request token!'
url = sess.build_authorize_url(request_token)
print url
raw_input()
access_token = sess.obtain_access_token(request_token)
client1 = client.DropboxClient(sess)
print client1.account_info()

我让程序在创建不同的对象时打印出消息,以便我可以看到错误发生的位置。这是输出:

aaron@Aarons-Ubuntu-Computer:~/Twisted$ python example.py
Creating session object
Session created!
Creating request token
Traceback (most recent call last):
File "example.py", line 8, in <module>
request_token = sess.obtain_request_token()
File "/usr/local/lib/python2.7/dist-packages/dropbox-1.4-py2.7.egg/dropbox/session.py", line 160, in obtain_request_token
response = rest.RESTClient.POST(url, headers=headers, params=params, raw_response=True)
File "/usr/local/lib/python2.7/dist-packages/dropbox-1.4-py2.7.egg/dropbox/rest.py", line 140, in POST
return cls.request("POST", url, post_params=params, headers=headers, raw_response=raw_response)
File "/usr/local/lib/python2.7/dist-packages/dropbox-1.4-py2.7.egg/dropbox/rest.py", line 64, in request
conn = ProperHTTPSConnection(host, 443)
File "/usr/local/lib/python2.7/dist-packages/dropbox-1.4-py2.7.egg/dropbox/rest.py", line 214, in __init__
self.cert_reqs = ssl.CERT_REQUIRED
AttributeError: 'module' object has no attribute 'CERT_REQUIRED'

我之前尝试过使用这段代码,但没有遇到这个问题。我也删除了 Dropbox SDK 并重新安装了它,但没有结果。是什么导致了这个问题,我该如何解决?

更新

添加 Kannan 的代码后,输出如下所示: 准备就绪 生成 session session 已生成!生成请求 token ['Certificate', 'CertificateOptions', 'CertificateRequest', 'Client', 'ClientContextFactory', 'Connector', 'ContextFactory', 'DN', 'DefaultOpenSSLContextFactory', 'DistinguishedName', 'KeyPair', 'Port ', 'PrivateCertificate', 'SSL', 'Server', '__all__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', 'implementedBy', 'implements', 'implementsOnly', '接口(interface)', '支持', 'tcp']然后我得到了错误。我曾尝试重新创建我的 SSL 证书,但没有成功。

最佳答案

我遇到了同样的错误。我尝试了你的建议,结果是 ssl 模块没有属性 'file',只有 ['doc', 'loader>', 'name', 'package'] 当我打印 dir(ssl) 时。另外值得注意的是,当我尝试在谷歌应用引擎中打印 str(ssl) 时,我看到:模块“ssl”(内置)但是当我从命令行运行 python 时,我看到:来自“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.pyc”的模块“ssl”命令行中的 ssl 有一个 file 属性。

不确定 ssl 是如何被劫持的......但我很确定它是。

编辑:loader 是 0x1142684d0 处的 google.appengine.tools.dev_appserver_import_hook.HardenedModulesHook 对象

编辑:在这里发现一个相关问题:SSLError on Google App Engine (local dev-server)

关于python - Dropbox Python SDK SSL 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10558088/

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