Skip to content

Conversation

@prashantpandeygit
Copy link
Contributor

Pull Request

Description

Convert auth0 400 bad request to 401 unauthorized, as the auth0-fastapi-api library returns error 400 by default for any kind of auth failures, changed the 400s to 401 as it was done before #170 with pyjwt

Fixes #173

@prashantpandeygit prashantpandeygit marked this pull request as ready for review January 9, 2026 12:34
@prashantpandeygit
Copy link
Contributor Author

@peterdudfield I have made the override, it will show 401(unauthorized) instead of 400, but will have the description of 401, so either we could keep it to show the correct description or replace the text with "unauthorized access attempt" and below it log the error, whatever you prefer. hope this helps, thanks!

claims = await validator_dependency(request)
except HTTPException as e:
if e.status_code == 400:
raise HTTPException(status_code=401, detail=e.detail) from e
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldnt we be raised 403 for unauthorized?
Is there a way to see the e error message? And only raise 403 id its an unauthorized error, but not other ones

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i did 401 as it was done previously with the pyjwt lib, but i will change it to 403 only for unauthorized

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dont get 403 if not authenticated

2 participants