4xx Client Error

HTTP 401 Unauthorized

The request requires user authentication. The client must provide valid credentials (such as a token or username/password) to access the resource. Despite the name, this is about authentication, not authorization.

Common Causes

  • Missing or expired authentication token
  • Invalid API key or credentials
  • Session has timed out and user needs to re-login
  • Authorization header format is incorrect

How to Fix

  1. 1Include a valid Authorization header with your request
  2. 2Refresh expired tokens or re-authenticate
  3. 3Check that credentials are correct and not revoked
  4. 4Verify the authentication scheme (Bearer, Basic, etc.)

Example

HTTP 401 Unauthorized
GET /api/profile HTTP/1.1

→ 401 Unauthorized
→ WWW-Authenticate: Bearer realm="api"

Related Client Error Codes