Skip to main content

Auth Error Codes

Complete reference for all authentication error codes returned by EdgeBase.

Error Response Format

All authentication errors return a consistent JSON structure:

{
"code": 400,
"message": "Human-readable error message.",
"data": {}
}
FieldTypeDescription
codenumberHTTP status code (400, 401, 403, 404, 409, 429, 500, 503)
messagestringHuman-readable description of the error
dataobjectOptional additional context (e.g., { "captcha_required": true })

Sign Up Errors

StatusMessageWhenHandling
400Email and password are required.Missing email or password field in request bodyShow form validation — highlight empty fields
400Invalid email format...Email fails format validationShow email-specific validation message
400Password must be at least 8 characters.Password shorter than 8 charactersShow password requirements hint
409Email already registered.An account with this email already existsSuggest signing in or resetting password
429Too many signup attempts...Signup rate limit exceededShow retry timer with countdown
403Auth hook 'beforeSignUp' rejected the operation.beforeSignUp hook returned a rejectionDisplay hook's custom message if provided

Sign In Errors

StatusMessageWhenHandling
400Email and password are required.Missing email or password fieldShow form validation
401Invalid credentials.Wrong email or wrong passwordShow generic error — do not reveal which field is incorrect
403This account uses OAuth sign-in. Password login is not available.User registered via OAuth, not email/passwordRedirect user to the appropriate OAuth provider
403Auth hook 'beforeSignIn' rejected the operation.beforeSignIn hook returned a rejectionDisplay hook's custom message if provided
429Too many login attempts...Sign-in rate limit exceeded (per email)Show retry timer with countdown

OAuth Errors

StatusMessageWhenHandling
400Unsupported OAuth provider: {provider}Provider name not recognizedCheck provider name spelling
400OAuth provider {provider} is not enabled.Provider not listed in allowedOAuthProviders configEnable provider in server config
500OAuth provider {provider} is not configured.Missing clientId or clientSecret env varsSet required environment variables
400OAuth error: {description}OAuth provider returned an error in callbackDisplay the provider's error description
400Missing code or state parameter.Callback URL missing required query paramsRestart the OAuth flow
400Invalid or expired OAuth state.State token expired (5 min TTL) or CSRF mismatchRestart the OAuth flow
400OAuth state provider mismatch.State token was issued for a different providerRestart the OAuth flow with the correct provider
409This OAuth account is already linked to another user.OAuth identity already associated with a different accountSign in with the linked account instead
409Email is already registered to another account.Email from OAuth provider conflicts with existing accountLink accounts or sign in with existing account

Anonymous Auth Errors

StatusMessageWhenHandling
404Anonymous authentication is not enabled.anonymousAuth is disabled in server configEnable anonymous auth in config or use a different auth method

Session & Token Errors

StatusMessageWhenHandling
400Refresh token is required.Missing refresh token in request bodyRe-authenticate the user
401Invalid refresh token.JWT decoding failed — malformed or tampered tokenClear stored tokens and re-authenticate
401Refresh token expired.Token TTL exceededClear stored tokens and re-authenticate
401Refresh token reuse detected. Session revoked.A previously used refresh token was replayed — possible token theft. All sessions for the user are revokedClear stored tokens and force full re-authentication
401Authentication required.Missing or invalid Authorization headerRedirect to sign-in page
Refresh Token Reuse Detection

When EdgeBase detects a refresh token being used more than once, it assumes the token was stolen. All sessions for that user are immediately revoked as a security measure. The legitimate user will need to sign in again.


Email Verification Errors

StatusMessageWhenHandling
400Verification token is required.Missing token in requestCheck the verification URL format
400Invalid or expired verification token.Token not found in the databaseRequest a new verification email
400Verification token has expired. Please request a new one.Token TTL exceeded (24 hours)Prompt user to request a new verification email

Password Reset Errors

StatusMessageWhenHandling
400Email is required.Missing email in reset requestShow form validation
400Password reset token is required.Missing token in reset confirmationCheck the reset URL format
400New password is required.Missing new password in reset confirmationShow form validation
400Password must be at least 8 characters.New password too shortShow password requirements
400Invalid or expired password reset token.Token not found in the databaseRequest a new password reset email
400Password reset token has expired. Please request a new one.Token TTL exceeded (1 hour)Prompt user to request a new reset email
403Password reset was blocked by the beforePasswordReset hook.beforePasswordReset hook returned a rejectionDisplay hook's custom message if provided

Change Password Errors

StatusMessageWhenHandling
400currentPassword and newPassword are required.Missing current or new passwordShow form validation
400Password must be at least 8 characters.New password too shortShow password requirements
401Current password is incorrect.Wrong current password enteredPrompt user to re-enter current password
403This account uses OAuth sign-in. Password login is not available.Account was created via OAuth — no password setPassword change is not applicable for OAuth accounts
403Anonymous accounts cannot change password.Anonymous user attempted password changeLink account with email first via account linking

Account Linking Errors

StatusMessageWhenHandling
400Email and password are required.Missing fields when linking with email/passwordShow form validation
400Password must be at least 8 characters.Weak password during email linkShow password requirements
400Only anonymous users can link with OAuth.Non-anonymous user attempted OAuth linkingOAuth linking is only available for anonymous accounts
409Email is already registered.Email already in use by another accountSuggest signing in with that email instead
409This OAuth account is already linked.OAuth identity already associated with another accountSign in with the linked account instead

Profile Update Errors

StatusMessageWhenHandling
400emailVisibility must be 'public' or 'private'.Invalid value for emailVisibility fieldUse only 'public' or 'private'
400No valid fields to update...Request body contains no recognized fieldsCheck available profile fields in the docs

Admin API Errors

StatusMessageWhenHandling
403Service Key required for admin auth operations.Admin endpoint called without a Service KeyInclude the Service Key in the request header
401Unauthorized. Service Key required.Invalid or expired Service Key providedVerify your Service Key in server config
404User not found.User ID does not exist in the databaseVerify the user ID before retrying

Captcha Errors

StatusMessageWhenHandling
403Captcha verification required.Captcha is enabled but no token was provided. Response includes data.captcha_required: trueRender captcha widget and retry with the token
403Captcha verification failed.Captcha token is invalid or expiredReset captcha widget and prompt user to retry
503Captcha service unavailable.Cloudflare Turnstile API is unreachable and failMode is closedShow a temporary error and retry after a delay
Captcha data field

When captcha verification is required, the error response includes extra context:

{
"code": 403,
"message": "Captcha verification required.",
"data": { "captcha_required": true }
}

Use the data.captcha_required flag to programmatically detect when to render the captcha widget.


Rate Limiting

StatusMessageWhenHandling
429Too many requests. Try again later.Global rate limit exceededBack off and retry after a delay
429Too many signup attempts...Signup-specific rate limit exceededShow retry timer
429Too many login attempts...Sign-in-specific rate limit exceeded (per email)Show retry timer
Rate Limit Strategy

Sign-in rate limits are tracked per email address to prevent brute-force attacks against specific accounts while not affecting other users.


SDK Error Handling

All EdgeBase client SDKs throw structured errors that include the code and message fields from the server response.

try {
const { user } = await client.auth.signIn({
email: 'user@example.com',
password: 'wrongPassword',
});
} catch (error) {
switch (error.code) {
case 401:
// Invalid credentials — show generic error
showError('Email or password is incorrect.');
break;
case 429:
// Rate limited — show retry message
showError('Too many attempts. Please try again later.');
break;
case 403:
if (error.message.includes('OAuth')) {
// OAuth-only account — redirect to OAuth provider
redirectToOAuth();
} else if (error.data?.captcha_required) {
// Captcha required — render widget
showCaptcha();
}
break;
default:
showError(error.message);
}
}

Quick Reference by Status Code

StatusMeaningCommon Causes
400Bad RequestMissing required fields, invalid format, expired tokens
401UnauthorizedInvalid credentials, expired/invalid tokens, missing auth header
403ForbiddenHook rejections, OAuth-only accounts, captcha required, anonymous restrictions
404Not FoundUser not found, feature not enabled
409ConflictDuplicate email, OAuth account already linked
429Too Many RequestsRate limits (global, signup, or signin)
500Internal Server ErrorMissing OAuth provider configuration
503Service UnavailableExternal service unreachable (e.g., Turnstile API)