401 Unauthorized

Authentication is missing or invalid.

4xx · Client error

What it means

The request has no valid credentials. Despite the name, it's about authentication (who are you?), not authorisation (are you allowed?).

The response must include a WWW-Authenticate header saying how to authenticate.

Why you're seeing it

  • A missing, expired or revoked token.
  • A wrong API key, or credentials sent in the wrong header.
  • A clock difference that makes a valid token look expired.

How to fix it

  • Send credentials in the format WWW-Authenticate asks for, e.g. Authorization: Bearer <token>.
  • Refresh the token and retry once.
  • If the user is logged in but not allowed, the server should send 403 instead.

Example response

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer realm="api", error="invalid_token"
Content-Type: application/json

{"error": "token_expired"}