Skip to content

Commit 692e45a

Browse files
fix: improve error handling for invalid authorization scheme and update test assertions
1 parent 9249fa2 commit 692e45a

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

packages/auth0_api_python/src/auth0_api_python/api_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ async def verify_request(
9393
raise self._prepare_error(MissingAuthorizationError())
9494
elif len(parts) > 2:
9595
raise self._prepare_error(
96-
InvalidAuthSchemeError("Invalid Authorization HTTP Header Format")
96+
InvalidAuthSchemeError("")
9797
)
9898

9999
scheme, token = parts

packages/auth0_api_python/tests/test_api_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1534,7 +1534,8 @@ async def test_verify_request_with_multiple_spaces_in_authorization():
15341534
)
15351535
with pytest.raises(InvalidAuthSchemeError) as err:
15361536
await api_client.verify_request({"authorization": "Bearer token with extra spaces"})
1537-
assert "authorization" in str(err.value).lower()
1537+
assert err.value.get_status_code() == 400
1538+
assert "invalid_request" in str(err.value.get_error_code()).lower()
15381539

15391540
@pytest.mark.asyncio
15401541
async def test_verify_request_fail_missing_dpop_header():

0 commit comments

Comments
 (0)