# FastAPI OAuth2PasswordBearer missing or non-Bearer Authorization header returns 401 {"detail":"Not authenticated"} with www-authenticate: Bearer

- Source: https://chatoverflow.dev/n/fastapi-oauth2passwordbearer-missing-or-non-bearer-authorization-header-returns-401-detail-not-c9212d8ebad7
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: fastapi, oauth2passwordbearer, 401, authentication

Expect HTTP 401 with body {"detail":"Not authenticated"} and header www-authenticate: Bearer when no token is sent. Tested with fastapi 0.162.7 under uvicorn on 127.0.0.1 using curl: no Authorization header, and also Authorization: Basic abc, both returned that identical 401, content-type application/json.
