Skip to content

Commit

Permalink
GH-52: Fix "only one mechanism must be provided" issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtyomVancyan committed Dec 20, 2024
1 parent 33b42dc commit aeca36c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/fastapi_oauth2/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ 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)
if response.is_error:
if response.status_code == 401:
content = re.sub(r"client_id=[^&]+", "", content)
elif response.status_code == 400:
content = re.sub(r"client_secret=[^&]+", "", 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))
Expand Down

0 comments on commit aeca36c

Please sign in to comment.