Auth Errors
Errors are deliberately uninformative in one place
Credential failures all look identical. That is a security property, not a gap — but it means debugging a sign-in needs a different approach, so this page says which errors carry information and which do not.
The shape
{
"success": false,
"error": { "code": "UNAUTHORIZED", "message": "The credentials provided are not valid." },
"meta": { "request_id": "req_..." }
}Switch on error.code rather than on the HTTP status — the codes are stable, and several share a status. Keep meta.request_id: it is what lets an operator find the matching server log.
One 401 covers every credential failure
UNAUTHORIZED — "The credentials provided are not valid." — is returned for a wrong password, an unknown user, an unverified identifier, an expired or already-used code, a wrong second factor, a banned account and a locked account alike. Response timing is equalised too. There is nothing to parse and no way to tell them apart from the client, by design: anything finer would let an attacker enumerate your users.By status
| Status | Code | Means, and what to do |
|---|---|---|
| 400 | VALIDATION_ERROR | The body failed schema validation, or a required capability token is missing. On sign-up this usually means a captcha or invitation is required — call auth-config to find out which |
| 400 | Password policy | The message names the rule that was missed — minimum length, a character class, or that the password appears in a breach corpus. Show it verbatim |
| 401 | UNAUTHORIZED | A credential failure. See above — nothing more is knowable client-side |
| 401 | INVALID_API_KEY | The key is wrong, revoked or expired. Distinct from the above: this is about your credential, not the user's |
| 403 | ACCESS_DENIED | Auth is not enabled on this project. The single most common first-call failure — Project Settings → Auth |
| 403 | INSUFFICIENT_PERMISSIONS | An operator endpoint called without owner or admin role, or a SCIM endpoint called with a non-SCIM token |
| 413 | — | The request body exceeded 64 KB, refused at the edge before reaching a function |
| 429 | RATE_LIMITED | Back off. See limits for the buckets |
| 500 | INTERNAL_ERROR | Ours. Keep the request_id and send it to support |
Refresh failures
auth-token collapses expired, revoked, reused, inactive, wrong-environment and wrong-project into the same opaque 401 — distinguishing them would tell an attacker whether the token they hold is real. Treat any 401 from refresh as "signed out": clear local state and show your sign-in surface.
One case is worth knowing about even though you cannot detect it: presenting a rotated-away refresh token kills the entire session family, so the legitimate user is signed out on every device. If a user reports being signed out everywhere for no reason, a token replay is the likely cause.
Second-factor failures need special handling
A 401 on the second factor means start over, not try again
mfa_token before it verifies the code, so a wrong code leaves that token dead. Retrying with it fails forever, on a screen the user often cannot dismiss. Distinguish the server answered from the request never arrived using the HTTP status: on a 401, restart from the first factor with a clear message; on a network error, the challenge was never consumed and a retry is correct.Errors with no error
The hardest failures here return 200. Each of these is a success response that did not do what you expected:
| Symptom | Cause |
|---|---|
| Code never arrives for a phone number | The dialling code is not in the project's allowlist, which defaults to +1 only. Refused before a message is queued |
| Code never arrives at all | Monthly SMS cap reached, or no email provider configured |
| Phone sign-in returns the opaque 401 with a correct code | identifier_kind was omitted, so the lookup searched email addresses |
| A returning user signs up and no code arrives | Sign-up issues a code only for a new identifier. Use auth-prepare |
| A user appears signed in but has no entitlements | ent_truncated was true and the list was read as complete |
| Switching organization changes nothing | set-active applies from the next refresh. Call auth-token |
Was this page helpful?
Or rate this page: