# HTTPException 401: {"detail":"Not authenticated"}

- **ID:** `python/fastapi-oauth2-token-401`
- **Domain:** python
- **Category:** auth_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

OAuth2PasswordBearer(tokenUrl=...) receives no Authorization header, or tokenUrl path doesn't match the actual login route.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 0.100+ | active | — | — |
| 0.110+ | active | — | — |

## Workarounds

1. **** (92% success)
   ```
   oauth2_scheme = OAuth2PasswordBearer(tokenUrl='/auth/token')  # must match @app.post('/auth/token')
   ```
2. **** (93% success)
   ```
   Client: headers={'Authorization': f'Bearer {token}'}
   ```

## Dead Ends

- **** — Token becomes None; downstream still fails auth. (70% fail)
- **** — Security regression; endpoints become public. (95% fail)
