我使用以下代码获取令牌以访问Google Calendar API。我不确定为什么我一直收到以下错误:
[Errno 1] _ssl.c:504: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed.
回溯:
File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-
packages/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
20. return view_func(request, *args, **kwargs)
File "/Users/aribaaboobakar/djcode/newProj/books/views.py" in auth_return
67. credential = FLOW.step2_exchange(request.REQUEST)
File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/google_api_python_client-1.2-py2.7.egg/oauth2client/util.py" in positional_wrapper
132. return wrapped(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/google_api_python_client-1.2-py2.7.egg/oauth2client/client.py" in step2_exchange
1283. headers=headers)
File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/httplib2-0.9-py2.7.egg/httplib2/__init__.py" in request
1593. (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/httplib2-0.9-py2.7.egg/httplib2/__init__.py" in _request
1335. (response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/httplib2-0.9-py2.7.egg/httplib2/__init__.py" in _conn_request
1257. conn.connect()
File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/httplib2-0.9-py2.7.egg/httplib2/__init__.py" in connect
1044. raise SSLHandshakeError(e)
Exception Type: SSLHandshakeError at /oauth2callback
Exception Value: [Errno 1] _ssl.c:504: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
def index(request):
storage = Storage(CredentialsModel, 'id', request.user, 'credential')
credential = storage.get()
if credential is None or credential.invalid == True:
FLOW.params['state'] = xsrfutil.generate_token(settings.SECRET_KEY,
request.user)
authorize_url = FLOW.step1_get_authorize_url()
return HttpResponseRedirect(authorize_url)
else:
http = httplib2.Http(disable_ssl_certificate_validation=True)
http = credential.authorize(http)
service = build("plus", "v1", http=http)
activities = service.activities()
activitylist = activities.list(collection='public',
userId='me').execute()
logging.info(activitylist)
return render_to_response('plus/welcome.html', {
'activitylist': activitylist,
})
@login_required
def auth_return(request):
if not xsrfutil.validate_token(settings.SECRET_KEY, request.REQUEST['state'],
request.user):
return HttpResponseBadRequest()
credential = FLOW.step2_exchange(request.REQUEST)
storage = Storage(CredentialsModel, 'id', request.user, 'credential')
storage.put(credential)
return HttpResponseRedirect("/")
答案 0 :(得分:0)
错误SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
几乎总是由于您的计算机或system time
上的CA is out-of-date and needs to be updated
设置不正确造成的。
检查计算机上的time and date
是否正确。