Skip to content

Commit

Permalink
Merge pull request #231 from masci/client_credential_contenttype
Browse files Browse the repository at this point in the history
Wrong Content-Type header returned by client credential grant
  • Loading branch information
ib-lundgren committed Jan 20, 2014
2 parents ab0e613 + 2000554 commit 0b02436
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion oauthlib/oauth2/rfc6749/grant_types/client_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def create_token_response(self, request, token_handler):
self.validate_token_request(request)
except errors.OAuth2Error as e:
log.debug('Client error in token request. %s.', e)
return {}, e.json, e.status_code
return headers, e.json, e.status_code

token = token_handler.create_token(request, refresh_token=False)
log.debug('Issuing token to client id %r (%r), %r.',
Expand Down
12 changes: 11 additions & 1 deletion tests/oauth2/rfc6749/grant_types/test_client_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,19 @@ def test_create_token_response(self):
self.assertIn('access_token', token)
self.assertIn('token_type', token)
self.assertIn('expires_in', token)
self.assertIn('Content-Type', headers)
self.assertEqual(headers['Content-Type'], 'application/json')

def test_error_response(self):
pass
bearer = BearerToken(self.mock_validator)
self.mock_validator.authenticate_client.return_value = False
headers, body, status_code = self.auth.create_token_response(
self.request, bearer)
error_msg = json.loads(body)
self.assertIn('error', error_msg)
self.assertEqual(error_msg['error'], 'invalid_client')
self.assertIn('Content-Type', headers)
self.assertEqual(headers['Content-Type'], 'application/json')

def test_validate_token_response(self):
# wrong grant type, scope
Expand Down

0 comments on commit 0b02436

Please sign in to comment.