我正在尝试访问BambooHR API(documentation here),但收到以下错误
params = {
'user': username,
'password': password,
'api_token': api_key}
url = 'https://api.bamboohr.com/api/gateway.php/company/v1/login'
r = requests.get(url, params=params)
错误:
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1580, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 964, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Users/chriscruz/Dropbox/PycharmProjects/082716_r2/Shippy/API/bamboo_api2.py", line 31, in <module>
BambooFunctions().login()
File "/Users/chriscruz/Dropbox/PycharmProjects/082716_r2/Shippy/API/bamboo_api2.py", line 26, in login
r = requests.get(url, params=params, auth=HTTPBasicAuth(api_key, 'api_token'))
File "/Library/Python/2.7/site-packages/requests/api.py", line 70, in get
return request('get', url, params=params, **kwargs)
File "/Library/Python/2.7/site-packages/requests/api.py", line 56, in request
return session.request(method=method, url=url, **kwargs)
File "/Library/Python/2.7/site-packages/requests/sessions.py", line 475, in request
resp = self.send(prep, **send_kwargs)
File "/Library/Python/2.7/site-packages/requests/sessions.py", line 596, in send
r = adapter.send(request, **kwargs)
File "/Library/Python/2.7/site-packages/requests/adapters.py", line 497, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: ("bad handshake: Error([('SSL routines', 'SSL23_GET_SERVER_HELLO', 'unknown protocol')],)",)
我不确定这是由于我重新安装了OpenSSL,请求,并且不确定如何解决此问题所造成的。
答案 0 :(得分:0)
您可以尝试设置verify = False,如果您使用的是自签名证书,请使用此选项。
r = requests.get(url, params=params, verify=False)
更多信息http://docs.python-requests.org/en/master/user/advanced/#ssl-cert-verification