diff --git a/oauthenticator/oauth2.py b/oauthenticator/oauth2.py index 0cf3c7df..9ba66ecf 100644 --- a/oauthenticator/oauth2.py +++ b/oauthenticator/oauth2.py @@ -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):