Skip to content

Commit

Permalink
fixes for oauthlib 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
masci committed Jul 20, 2015
1 parent 764b83c commit 6f97011
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
21 changes: 14 additions & 7 deletions oauth2_provider/oauth2_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ def _authenticate_basic_auth(self, request):
if not auth_string:
return False

encoding = request.encoding or 'utf-8'
try:
encoding = request.encoding
except AttributeError:
encoding = 'utf-8'

try:
b64_decoded = base64.b64decode(auth_string)
Expand Down Expand Up @@ -91,10 +94,10 @@ def _authenticate_request_body(self, request):
directly utilize the HTTP Basic authentication scheme. See rfc:`2.3.1` for more details.
"""
# TODO: check if oauthlib has already unquoted client_id and client_secret
client_id = request.client_id
client_secret = request.client_secret

if not client_id or not client_secret:
try:
client_id = request.client_id
client_secret = request.client_secret
except AttributeError:
return False

if self._load_application(client_id, request) is None:
Expand Down Expand Up @@ -143,8 +146,12 @@ def client_authentication_required(self, request, *args, **kwargs):
if self._extract_basic_auth(request):
return True

if request.client_id and request.client_secret:
return True
try:
if request.client_id and request.client_secret:
return True
except AttributeError:
log.debug("Client id or client secret not provided, proceed evaluating if authentication is required...")
pass

self._load_application(request.client_id, request)
if request.client:
Expand Down
2 changes: 1 addition & 1 deletion oauth2_provider/tests/test_authorization_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def test_pre_auth_wrong_response_type(self):

response = self.client.get(url)
self.assertEqual(response.status_code, 302)
self.assertIn("error=unauthorized_client", response['Location'])
self.assertIn("error=unsupported_response_type", response['Location'])

def test_code_post_auth_allow(self):
"""
Expand Down

0 comments on commit 6f97011

Please sign in to comment.