I'm writing a program to invite several Windows Live Contacts into a web application, all in Django 1.4. I'm experiencing the following problem.
I'm able to log the user in Windows Live using his account credentials through the Windows Live REST API by using this piece of code
def hotmail(request):
auth_params = {
'client_id': settings.HOTMAIL_KEY,
'scope': 'wl.basic',
'response_type': 'code',
'redirect_uri': 'http://my_testing_comain/hotmail/process'
}
auth_url = settings.HOTMAIL_AUTH_URL % urllib.urlencode(auth_params)
return HttpResponseRedirect(auth_url)
Then, I receive an Authorization Code that I exchange for an Access Token (according to the OAuth Protocol) this is the piece of code I use to process the Windows Live's response:
def hotmail_process(request):
if request.method == 'GET':
parameters = {
'code': request.GET['code'],
'grant_type': 'authorization_code',
'redirect_uri': 'http://my_testing_url/hotmail/process',
'client_id': settings.HOTMAIL_KEY,
'client_secret': settings.HOTMAIL_SECRET,
}
response = urllib2.urlopen(settings.HOTMAIL_AUTH_URL % urllib.urlencode(parameters)).read()
response = simplejson.loads(response)
consumer = oauth.Consumer(settings.HOTMAIL_KEY, settings.HOTMAIL_SECRET)
client = oauth.Client(consumer)
contacts = client.request(settings.HOTMAIL_USER_FRIENDS_URI % response['access_token'])
return HttpResponse(simplejson.loads(contacts))
return HttpResponse('Invalid request')
But I get the following error:
SSLHandshakeError at /hotmail/process/
[Errno 1] _ssl.c:499: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Request Method: GET
Request URL: http://my_testing_url/hotmail/process/?code=5330307c-664c-4d5b-27b3-a19a97bc8546
Django Version: 1.4
Exception Type: SSLHandshakeError
Exception Value:
[Errno 1] _ssl.c:499: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
and the following traceback:
Environment:
Request Method: GET
Request URL: http://my_testing_url/hotmail/process/?code=5330307c-664c-4d5b-27b3-a19a97bc8546
Django Version: 1.4
Python Version: 2.7.1
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
'contacts')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
Traceback:
File "/home/user/virtenvs/israel/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "/home/user/virtenvs/israel/networks/contacts/views.py" in hotmail_process
26. contacts = client.request(settings.HOTMAIL_USER_FRIENDS_URI % response['access_token'])
File "/home/user/virtenvs/israel/lib/python2.7/site-packages/oauth2/__init__.py" in request
682. connection_type=connection_type)
File "/home/user/virtenvs/israel/lib/python2.7/site-packages/httplib2/__init__.py" in request
1544. (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "/home/user/virtenvs/israel/lib/python2.7/site-packages/httplib2/__init__.py" in _request
1294. (response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "/home/user/virtenvs/israel/lib/python2.7/site-packages/httplib2/__init__.py" in _conn_request
1230. conn.connect()
File "/home/user/virtenvs/israel/lib/python2.7/site-packages/httplib2/__init__.py" in connect
1005. raise SSLHandshakeError(e)
Exception Type: SSLHandshakeError at /hotmail/process/
Exception Value: [Errno 1] _ssl.c:499: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
The thing is that, if I delete the line where I do the client.request() for this:
return HttpResponseRedirect(settings.HOTMAIL_USER_FRIENDS_URI % response['access_token'])
I get the contacts in json format in my browser
So, apparently, my python oauth2 lib is missing some certificates (or that's what I think), so I tried this Python - SSL Issue with Oauth2 with no results. I also tried some libraries before I found out that they were deprecated. I've also tried to do it with the plain REST API call but I got a "FORBIDEN" response.
My oauth2 library works fine because I was able to implement the same functionality with GMail.
Any help or hint will be truly appreciated.
Thank you in advance.
Why not just do this?