Replies: 2 comments
-
|
Can you share full code example? |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Closing this. Feel free to reopen it when you are ready to provide more info |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
Description
I'm encountering an intermittent issue with my FastAPI application where the Authorization headers switch from Bearer token to Basic auth without any changes to the request being made. This issue resolves itself without any clear intervention, making it particularly perplexing. The application is containerised using Docker, and I'm testing the endpoints using the auto-docs generated by FastAPI.
Running the above code, I kept receiving a 403 response with the message "Invalid authentication credentials". This is the response that FastAPI automatically returns when the authorization scheme of the request Header is not equal to
"bearer".When sending a
GETrequest to my FastAPI endpoint with aBearertoken in theAuthorizationheader, the application sometimes logs theAuthorizationheader asBasicauth instead. This issue appears randomly and resolves itself after some time. Below are the details of thecurlcommand and the logs from two different attempts:First Attempt Log (Issue Present):
Second Attempt Log (Issue Resolved, 17 minutes later):
Attempts to Diagnose/Resolve the Issue:
Are there known issues with FastAPI's
HTTPBearerclass that might cause this intermittent recognition ofBearervs.Basicauth headers? Can anyone shed some light on how I might go about fixing this issue?Any insights, experiences, or suggestions would be greatly appreciated. Thank you in advance for your help!
Operating System
macOS
Operating System Details
FastAPI Version
0.109.2
Pydantic Version
2..5.1
Python Version
Python 3.11.8
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions