Skip to content

Commit 79e0455

Browse files
Fix "only one mechanism must be provided" issue (GH-54)
2 parents 33b42dc + 6cb6ba1 commit 79e0455

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

.github/workflows/tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
jobs:
1010
test:
11-
runs-on: "ubuntu-latest"
11+
runs-on: "ubuntu-22.04"
1212
strategy:
1313
matrix:
1414
include:

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ packages =
4343
fastapi_oauth2
4444
install_requires =
4545
fastapi>=0.68.1
46-
httpx>=0.23.0
46+
httpx>=0.23.0,<=0.27.2
4747
oauthlib>=3.2.2
4848
python-jose>=3.3.0
4949
social-auth-core>=4.4.2

src/fastapi_oauth2/core.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,11 @@ async def token_data(self, request: Request, **httpx_client_args) -> dict:
125125
async with httpx.AsyncClient(auth=auth, **httpx_client_args) as session:
126126
try:
127127
response = await session.post(token_url, headers=headers, content=content)
128-
if response.status_code == 401:
129-
content = re.sub(r"client_id=[^&]+", "", content)
128+
if response.is_error:
129+
if response.status_code == 401:
130+
content = re.sub(r"client_id=[^&]+", "", content)
131+
elif response.status_code == 400:
132+
content = re.sub(r"client_secret=[^&]+", "", content)
130133
response = await session.post(token_url, headers=headers, content=content)
131134
self._oauth_client.parse_request_body_response(json.dumps(response.json()))
132135
return self.standardize(self.backend.user_data(self.access_token))

0 commit comments

Comments
 (0)