# fastapi.exceptions.HTTPException: 401 Unauthorized: {"detail":"Not authenticated"}

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

## Root Cause

OAuth2PasswordBearer dependency did not receive an Authorization: Bearer header, or the token was rejected.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 0.100.x | active | — | — |
| 0.110.x | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   headers = {'Authorization': f'Bearer {token}'}\nrequests.get(url, headers=headers)
   ```
2. **** (90% success)
   ```
   from fastapi.security import HTTPBearer\nsecurity = HTTPBearer(auto_error=False)
   ```

## Dead Ends

- **** — Returns None token and downstream logic still fails. (80% fail)
- **** — OAuth2PasswordBearer expects the Authorization header by default. (85% fail)
