Skip to content

Commit

Permalink
Merge pull request #698 from yaleman/oauth2-bearer
Browse files Browse the repository at this point in the history
Correcting Bearer Authorization header in OAuth2
  • Loading branch information
GeorgianaElena authored Nov 21, 2023
2 parents 7015b01 + dee2609 commit 0a06daf
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion oauthenticator/oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,10 +716,17 @@ def build_userdata_request_headers(self, access_token, token_type):
Builds and returns the headers to be used in the userdata request.
Called by the :meth:`oauthenticator.OAuthenticator.token_to_user`
"""

# token_type is case-insensitive, but the headers are case-sensitive
if token_type.lower() == "bearer":
auth_token_type = "Bearer"
else:
auth_token_type = token_type

return {
"Accept": "application/json",
"User-Agent": "JupyterHub",
"Authorization": f"{token_type} {access_token}",
"Authorization": f"{auth_token_type} {access_token}",
}

def build_token_info_request_headers(self):
Expand Down

0 comments on commit 0a06daf

Please sign in to comment.