Reference

Error reference

Protocol and TypeScript client error codes, likely causes, and safe recovery actions.

Use this page as a lookup for handled protocol and client failures. Never include authorization codes, tokens, PKCE verifiers, cookies, private keys, or raw provider responses in logs or user-visible error reports.

Token endpoint errors

Handled POST /token failures use HTTP 400 and an OAuth-style response:

{
  "error": "invalid_grant",
  "code": "EXPIRED_CODE",
  "error_description": "Authorization code is expired"
}

Validation errors may omit the project-specific code.

ConditionerrorcodeSafe recovery
Missing or invalid form fieldinvalid_requestNoneFix request construction
Wrong grant_typeunsupported_grant_typeNoneSend authorization_code
Missing client IDinvalid_requestMISSING_CLIENT_IDSend the origin: client ID
Code cannot be decrypted/decodedinvalid_grantINVALID_CODERestart sign-in; do not reuse the callback
Code expiredinvalid_grantEXPIRED_CODERestart sign-in
Client ID mismatchinvalid_grantINVALID_CLIENT_IDUse the callback origin that started the flow
Redirect URI mismatchinvalid_grantINVALID_REDIRECT_URISend the exact original redirect URI string
Required verifier missinginvalid_grantMISSING_VERIFIERRestore the pending verifier or restart sign-in
Verifier does not matchinvalid_grantINVALID_VERIFIERRestart sign-in with the matching stored verifier
Code-use record already existsinvalid_grantUSED_CODERestart sign-in; never retry the same code

A client ID without origin: may receive the hint Try again with "origin:" prefix.

Userinfo errors

GET /userinfo returns HTTP 401 for bearer-token failures:

ConditionResponse
Missing or malformed bearer header{ "error": "invalid_token", "error_description": "Missing bearer token" }
Expired token{ "error": "invalid_token", "error_description": "Token is expired" }
Other invalid token{ "error": "invalid_token", "error_description": "Invalid token" }

Prompt the user to sign in again for expired or invalid tokens. Do not repeatedly retry the same credential.

Client result errors

Client auth methods normally return:

{ data: null, error }

Branch by the exported classes:

import {
  APIUnboundError,
  AuthUnboundError,
} from "unbound-auth";

const { data, error } = await auth.finishSignIn();

if (error instanceof AuthUnboundError) {
  // Use error.code for controlled auth recovery.
} else if (error instanceof APIUnboundError) {
  // Use error.code and error.status; keep error.cause private.
} else if (error) {
  // Unexpected runtime, storage, listener, or adapter error.
}

Authentication codes

CodeLikely causeRecovery
MISSING_REDIRECT_URINo resolvable HTTP(S) callbackConfigure a browser path or absolute server callback
MISSING_SCOPESNo supported scope remainsRequest at least one of openid, profile, or email
MISSING_CODECallback has no codeIf denied, handle error; otherwise restart sign-in
MISSING_STATECallback has no state or pending state was lostHandle denial separately or restart sign-in
MISSING_VERIFIERPKCE verifier was lost or wrong storage/tab usedRestart sign-in in the original tab
MISSING_CLIENT_IDToken request has no client IDCorrect request/client configuration
INVALID_REDIRECT_URIURI is unsupported or differs from the originalUse an HTTP(S) URI and exact original value
INVALID_CODEMalformed, undecryptable, or invalid codeRestart sign-in
INVALID_STATEReturned state differs from stored stateStop processing and restart sign-in
INVALID_VERIFIERPKCE verification failedRestart sign-in; do not reuse pending values
INVALID_CLIENT_IDApp origin/client ID differsUse the same callback origin throughout the flow
EXPIRED_CODECode exceeded its short lifetimeRestart sign-in
USED_CODECode was already recorded as exchangedRestart sign-in
MISSING_TOKENsetSession() received an empty tokenSupply a token only from a trusted exchange
INVALID_TOKENToken shape, /userinfo, or signature check failedClear local session state and sign in again
EXPIRED_TOKENJWT or /userinfo reports expirationPrompt sign-in and create a new app session

INVALID_STATE is declared and can be produced by browser callback validation. It is also recognized if returned by the token API, although the current token endpoint table does not normally emit it.

API errors

APIUnboundError.codeMeaningAvailable contextRecovery
NETWORK_ERRORFetch, JSON parsing, or unexpected request failurecauseCheck connectivity/CORS; retry only idempotent checks
SERVER_ERRORNon-mapped HTTP failure or invalid success responsestatus, sometimes causeInspect status/content type; retry later or report a sanitized incident
UNKNOWNDeclared fallback codeOptional contextNot currently constructed by normal inspected paths

For /userinfo, an HTTP 401 whose description contains expired maps to EXPIRED_TOKEN; other 401 responses map to INVALID_TOKEN. Other non-2xx responses map to SERVER_ERROR.

User denial

A denial returns error=access_denied to the callback, but current denial redirects omit state. Automatic callback completion only starts when both code and state exist, and manual finishSignIn() can otherwise report MISSING_STATE or MISSING_CODE.

Inspect the callback's error parameter before calling finishSignIn(). Treat access_denied as a user-controlled cancellation, clear or replace the callback URL, and return to a neutral signed-out state. Do not report it as a security incident.

HTML and unexpected responses

Not every endpoint failure is structured JSON:

  • malformed /authorize requests render HTML validation;
  • invalid consent submissions can redirect back to an HTML page;
  • an unconfigured service can render an HTML setup page for protocol routes;
  • unexpected server failures can render a generic HTML retry page;
  • upstream provider failures are presented through generic user-facing UI rather than raw provider errors.

Before parsing JSON, check response.ok as appropriate and inspect Content-Type. Convert unexpected HTML to a sanitized app error; do not display or log an entire response body by default.

Retry rules

Failure categoryRecommended action
Invalid app configurationFix callback, origin, scope, or endpoint configuration before retrying
State, verifier, code, or denial issueDiscard the callback and restart authorization
Expired or used codeAlways start a new flow
Expired or invalid tokenClear the app session and prompt sign-in
CORS or browser network failureUse supported CORS infrastructure or a backend/same-origin exchange
Temporary /userinfo network failureRetry with bounded backoff if the app can do so safely
Unexpected HTML/server failureShow a generic retry message and record sanitized status/metadata

See Troubleshooting for symptom-first app guidance and Endpoint reference for request requirements.

On this page