From 770d9620f13506f3db52059c5d04a283181a3b48 Mon Sep 17 00:00:00 2001 From: Artyom Vancyan Date: Sat, 3 Aug 2024 14:25:10 +0400 Subject: [PATCH] Fix "Cannot supply multiple client credentials." error for Okta users --- src/fastapi_oauth2/core.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/fastapi_oauth2/core.py b/src/fastapi_oauth2/core.py index e7571b3..5e24f6f 100644 --- a/src/fastapi_oauth2/core.py +++ b/src/fastapi_oauth2/core.py @@ -124,6 +124,9 @@ async def token_data(self, request: Request, **httpx_client_args) -> dict: async with httpx.AsyncClient(auth=auth, **httpx_client_args) as session: try: response = await session.post(token_url, headers=headers, content=content) + if response.status_code == 401: + content = re.sub(r"client_id=[^&]+", "", content) + response = await session.post(token_url, headers=headers, content=content) self._oauth_client.parse_request_body_response(json.dumps(response.json())) return self.standardize(self.backend.user_data(self.access_token)) except (OAuth2Error, httpx.HTTPError) as e: