SDK recovers from most authentication errors automatically. This guide helps you handle the exceptions and show appropriate messages to users. Typical entry points:Documentation Index
Fetch the complete documentation index at: https://docs.discovr.media/llms.txt
Use this file to discover all available pages before exploring further.
signInWithPopup(), signInWithWebAuth(), signInWithDeviceCode(), then selectProfile() and API calls such as createPage().
When sign-in fails
- User cancelled: Don’t show error. User made a choice.
- Network error: Show retry button. Prompt: “Check your connection and try again.”
- Invalid credentials: Show error. Prompt: “Email or password incorrect. Try again.”
- Other errors: Show generic message. Prompt: “Sign-in failed. Try again.”
When API calls fail
The same client is used after sign-in—for examplecreatePage()—and errors below can surface on any session-scoped request.
| Error Code | Meaning | What to show user |
|---|---|---|
TOKEN_INVALID | Malformed auth header or missing token | ”Session invalid. Please sign in again.” |
TOKEN_EXPIRED | Session or refresh token expired | ”Session expired. Please sign in again.” |
SESSION_EXPIRED | Page was created in older session (e.g., opened in different tab/device) | “Page session expired. Please refresh.” (SDK usually handles) |
WRONG_TOKEN_KIND | Sent session token to identity endpoint (or vice versa)—SDK bug | ”Internal error. Refresh page.” (Report if persists) |
NETWORK_ERROR | Network timeout, DNS failure, or connectivity issue | ”Network error. Check your connection and try again.” |
| Network 401/403 | Authorization failed | ”Session invalid. Please sign in again.” |
| Other errors | Server error, validation error, or unexpected | ”Something went wrong. Try again.” (Include error ID for support) |
SDK error recovery
SDK automatically handles:- Token refresh: Before token expires, SDK mints a fresh one. Transparent to your code.
- Retry logic: If token expires mid-request, SDK refreshes and retries. You see no errors.
- Snapshot recovery: If page session expires, SDK recovers using stored page filters. Usually transparent.
- Sign-in failures (network, cancelled, auth failure)
- Persistent token errors (token truly invalid/revoked)
- Network errors (timeout, connectivity)
Error handling best practices
Do:- Show user-friendly messages (“Sign-in failed. Try again.”)
- Provide retry buttons for network errors
- Log errors for debugging (but never log tokens)
- Handle offline gracefully
- Show technical error messages to users (“TOKEN_EXPIRED_INVALID_SIGNATURE”)
- Log or expose tokens
- Retry indefinitely without backoff
- Assume error codes—check for multiple possible codes (e.g., both
TOKEN_INVALIDandTOKEN_EXPIRED)
Related SDK reference
signInWithPopup · signInWithWebAuth · signInWithDeviceCode · selectProfile · createPageNext: Learn security best practices