Skip to content

Commit

Permalink
rm comma after Bearer in WWW-Authenticate header
Browse files Browse the repository at this point in the history
  • Loading branch information
freeman1981 authored and auvipy committed Nov 14, 2021
1 parent ff24e70 commit f671011
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
7 changes: 2 additions & 5 deletions oauthlib/oauth2/rfc6749/errors.py
Expand Up @@ -103,15 +103,12 @@ def headers(self):
value "Bearer". This scheme MUST be followed by one or more
auth-param values.
"""
authvalues = [
"Bearer",
'error="{}"'.format(self.error)
]
authvalues = ['error="{}"'.format(self.error)]
if self.description:
authvalues.append('error_description="{}"'.format(self.description))
if self.uri:
authvalues.append('error_uri="{}"'.format(self.uri))
return {"WWW-Authenticate": ", ".join(authvalues)}
return {"WWW-Authenticate": "Bearer " + ", ".join(authvalues)}
return {}


Expand Down
4 changes: 2 additions & 2 deletions tests/oauth2/rfc6749/endpoints/test_introspect_endpoint.py
Expand Up @@ -87,7 +87,7 @@ def test_introspect_token_client_authentication_failed(self):
'Content-Type': 'application/json',
'Cache-Control': 'no-store',
'Pragma': 'no-cache',
"WWW-Authenticate": 'Bearer, error="invalid_client"'
"WWW-Authenticate": 'Bearer error="invalid_client"'
})
self.assertEqual(loads(b)['error'], 'invalid_client')
self.assertEqual(s, 401)
Expand Down Expand Up @@ -115,7 +115,7 @@ def test_introspect_token_public_client_authentication_failed(self):
'Content-Type': 'application/json',
'Cache-Control': 'no-store',
'Pragma': 'no-cache',
"WWW-Authenticate": 'Bearer, error="invalid_client"'
"WWW-Authenticate": 'Bearer error="invalid_client"'
})
self.assertEqual(loads(b)['error'], 'invalid_client')
self.assertEqual(s, 401)
Expand Down
4 changes: 2 additions & 2 deletions tests/oauth2/rfc6749/endpoints/test_revocation_endpoint.py
Expand Up @@ -55,7 +55,7 @@ def test_revoke_token_client_authentication_failed(self):
'Content-Type': 'application/json',
'Cache-Control': 'no-store',
'Pragma': 'no-cache',
"WWW-Authenticate": 'Bearer, error="invalid_client"'
"WWW-Authenticate": 'Bearer error="invalid_client"'
})
self.assertEqual(loads(b)['error'], 'invalid_client')
self.assertEqual(s, 401)
Expand Down Expand Up @@ -83,7 +83,7 @@ def test_revoke_token_public_client_authentication_failed(self):
'Content-Type': 'application/json',
'Cache-Control': 'no-store',
'Pragma': 'no-cache',
"WWW-Authenticate": 'Bearer, error="invalid_client"'
"WWW-Authenticate": 'Bearer error="invalid_client"'
})
self.assertEqual(loads(b)['error'], 'invalid_client')
self.assertEqual(s, 401)
Expand Down

0 comments on commit f671011

Please sign in to comment.