401 Unauthorized
Authentication is required or the credentials/token are invalid.
Common causes
- Not logged in or missing Authorization header
- Expired token / JWT, bad signature or wrong format (missing "Bearer ")
- Wrong or revoked API key
How to fix
- Log in again or get a new token (refresh token)
- Inspect the JWT with a JWT decoder: exp, issuer, audience
- On the server: send a WWW-Authenticate header describing the auth scheme
Detailed reference (MDN) ↗RFC 9110 §15.5.2 ↗
Which code should I use?
- 401 / 403: 401: not logged in or the token is wrong / expired; logging in again may work. 403: you are known but not allowed; logging in again will not help.
