Authentication is required or the supplied credentials are invalid.
401 Unauthorized really means "unauthenticated": the request lacks valid credentials for the target resource. The server must send a WWW-Authenticate header naming the scheme(s) it accepts (Basic, Bearer, Digest, Negotiate). If the user is authenticated but not allowed, the correct code is 403.
Authorization header (e.g. an expired OAuth/JWT access token).auth_basic) or Apache (AuthType Basic) protected paths; browsers show a login prompt.Bearer realm="api", error="invalid_token" (RFC 6750 error codes).Authorization: Bearer <token> with exactly one space and no quotes.user:password; curl does this with -u user:pass.| Header | Role |
|---|---|
WWW-Authenticate | Required: the challenge with scheme and realm. |
Authorization | Request header carrying credentials. |
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer realm="api", error="invalid_token", error_description="The access token expired"
Content-Type: application/json
{"error": "invalid_token"}