@http · HTTP status codes, explained HTTP/1.1 401 Unauthorized ━━━━━━━━━━━━━━━━━━━━━━━━━ 4xx · Client error Authentication is missing or invalid. 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 . → 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"} related 403 Forbidden   407 Proxy Authentication Required   400 Bad Request spec RFC 9110 §15.5.2 https://www.rfc-editor.org/rfc/rfc9110#section-15.5.2 web https://athttp.com/401 ← curl athttp.com/400 curl athttp.com/402 →