Skip to content

Commit

Permalink
Fix "only one mechanism must be provided" issue (GH-54)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtyomVancyan authored Dec 20, 2024
2 parents 33b42dc + 6cb6ba1 commit 79e0455
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
test:
runs-on: "ubuntu-latest"
runs-on: "ubuntu-22.04"
strategy:
matrix:
include:
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ packages =
fastapi_oauth2
install_requires =
fastapi>=0.68.1
httpx>=0.23.0
httpx>=0.23.0,<=0.27.2
oauthlib>=3.2.2
python-jose>=3.3.0
social-auth-core>=4.4.2
Expand Down
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 79e0455

Please sign in to comment.