API error guides: OAuth2, JWT and CORS
Short guides for the errors that cost the most time. Each one asks a few questions to find your cause, then lists every cause and its fix.
OAuth2 "invalid_grant"
invalid_grant at the token endpoint: an authorization code or refresh token that is expired, already used, revoked, or does not match the request.
JWT "invalid signature"
A JWT fails with invalid signature: wrong secret or key, key rotation, wrong algorithm, a modified or truncated token.
JWT "expired" (exp)
A JWT is rejected as expired: lifetime too short, clock skew, exp in milliseconds instead of seconds, or no refresh logic.
OAuth2 "redirect_uri mismatch"
redirect_uri_mismatch or invalid redirect URI: the URI sent does not exactly match one registered for the client.
OAuth2 "invalid_client"
invalid_client at the token endpoint: wrong client ID or secret, wrong authentication method (Basic vs body), public vs confidential client, or the wrong environment.
CORS error
The browser blocks a request with a CORS error: missing Access-Control-Allow-Origin, failing preflight, wildcard with credentials, missing headers.
Paste an error and see its causes in the OAuth2 error doctor, or decode a token in the JWT inspector.