Commits

David Larlet committed 5e80d27

Retrieveing fixes from @ditto's fork: better error handling

Comments (0)

Files changed (2)

oauth_provider/utils.py

     if request.method == "POST" and \
         (request.META.get('CONTENT_TYPE') == "application/x-www-form-urlencoded" \
             or request.META.get('SERVER_NAME') == 'testserver'):
-        parameters = dict(request.REQUEST.items())
+        parameters = dict((k, v.encode('utf-8')) for (k, v) in request.REQUEST.iteritems())
 
     oauth_request = oauth.Request.from_request(request.method, 
                                               request.build_absolute_uri(request.path), 
     return oauth.Request.from_request(request.method, 
                                       request.build_absolute_uri(request.path), 
                                       headers, 
-                                      dict(request.REQUEST))
+                                      dict((k, v.encode('utf-8')) for (k, v) in request.REQUEST.iteritems()))
 
 def verify_oauth_request(request, oauth_request, consumer, token=None):
     """ Helper function to verify requests. """

oauth_provider/views.py

 from django.conf import settings
 from django.contrib.auth.decorators import login_required
 from django.http import HttpResponse, HttpResponseBadRequest, HttpResponseRedirect
-from django.shortcuts import render_to_response
-from django.template import RequestContext
 from django.views.decorators.csrf import csrf_exempt
 from django.utils.translation import ugettext as _
 from django.core.urlresolvers import get_callable
 @csrf_exempt
 def access_token(request):
     oauth_request = get_oauth_request(request)
+    if oauth_request is None:
+        return INVALID_PARAMS_RESPONSE
 
     missing_params = require_params(oauth_request, ('oauth_token', 'oauth_verifier'))
     if missing_params is not None: