我正在尝试使用Google的Oauth连接到Google adsense并收到此错误。 有什么线索可以解决它吗?
之前有人在python中遇到过这样的问题吗?
Traceback (most recent call last):
File "get_all_saved_reports.py", line 56, in <module>
main(sys.argv)
File "get_all_saved_reports.py", line 36, in main
service = sample_utils.initialize_service()
File "/home/nish/Programs/python/google-adsense/samples/adsense/sample_utils.py", line 114, in initialize_service
credentials = prepare_credentials()
File "/home/nish/Programs/python/google-adsense/samples/adsense/sample_utils.py", line 95, in prepare_credentials
credentials = run(FLOW, storage)
File "/usr/local/lib/python2.7/dist-packages/oauth2client-1.1-py2.7.egg/oauth2client/util.py", line 128, in positional_wrapper
return wrapped(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/oauth2client-1.1-py2.7.egg/oauth2client/tools.py", line 197, in run
credential = flow.step2_exchange(code, http=http)
File "/usr/local/lib/python2.7/dist-packages/oauth2client-1.1-py2.7.egg/oauth2client/util.py", line 128, in positional_wrapper
return wrapped(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/oauth2client-1.1-py2.7.egg/oauth2client/client.py", line 1283, in step2_exchange
headers=headers)
File "/usr/local/lib/python2.7/dist-packages/httplib2-0.8-py2.7.egg/httplib2/__init__.py", line 1571, in request
(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "/usr/local/lib/python2.7/dist-packages/httplib2-0.8-py2.7.egg/httplib2/__init__.py", line 1318, in _request
(response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "/usr/local/lib/python2.7/dist-packages/httplib2-0.8-py2.7.egg/httplib2/__init__.py", line 1253, in _conn_request
conn.connect()
File "/usr/local/lib/python2.7/dist-packages/httplib2-0.8-py2.7.egg/httplib2/__init__.py", line 1022, in connect
self.disable_ssl_certificate_validation, self.ca_certs)
File "/usr/local/lib/python2.7/dist-packages/httplib2-0.8-py2.7.egg/httplib2/__init__.py", line 80, in _ssl_wrap_socket
cert_reqs=cert_reqs, ca_certs=ca_certs)
File "/usr/lib/python2.7/ssl.py", line 381, in wrap_socket
ciphers=ciphers)
File "/usr/lib/python2.7/ssl.py", line 141, in __init__
ciphers)
ssl.SSLError: [Errno 185090050] _ssl.c:340: error:0B084002:x509 certificate routines:X509_load_cert_crl_file:system lib
答案 0 :(得分:30)
我使用Python 2.7.5在oauth2(对于Twitter API,而不是Google)中得到了这个确切的x509错误,并使用了Akshay Valsa的建议并使用
更改了cacerts.txt的权限chmod 644 /usr/local/lib/python2.7/dist-packages/httplib2-0.8-py2.7.egg/httplib2/cacerts.txt
解决了这个问题,现在我可以像普通用户一样运行我的模块而不是sudoing它。 谢谢!
答案 1 :(得分:7)
此问题是在加载证书文件时。如果您使用root用户运行该程序,则此问题将得到解决。 或者,您可以检查文件的权限:/usr/local/lib/python2.7/dist-packages/httplib2-0.8-py2.7.egg/httplib2/cacerts.txt,并为此文件提供必要的权限。
答案 2 :(得分:1)
在我的情况下,我正在运行Django开发服务器。如果服务器在切换到虚拟环境之前运行,我发现[Errno 185090050] _ssl.c:345:错误:0B084002:x509证书例程:X509_load_cert_crl_file:我的回溯中的系统库。简单地说,我不再运行创建证书的httplib2版本:我可能正在运行dist-package。 (Ububtu 13.10),Python 2.7,Django 1.62。希望这有助于其他人。
答案 3 :(得分:0)
我找到了解决方案。 谷歌OAuth很难理解,我必须首次以sudo / root身份运行脚本。那很有效。还要确保正确设置权限。