Auth Backend issues two tokens after a successful authentication:Documentation Index
Fetch the complete documentation index at: https://mintlify.com/eggarcia98/auth-backend/llms.txt
Use this file to discover all available pages before exploring further.
- Access token — a short-lived JWT used to prove identity on every request.
- Refresh token — a long-lived token used to obtain a new access token without requiring the user to log in again.
POST /verify-otp returns tokens directly in the response body without setting cookies, leaving storage to the client.
Cookie configuration
Tokens are set on the response by the controller with the following attributes:| Attribute | Access token | Refresh token |
|---|---|---|
httpOnly | true | true |
secure | true in production | true in production |
sameSite | strict (email/password) / lax (OAuth) | strict (email/password) / lax (OAuth) |
maxAge | expiresIn from Supabase session (seconds) | 7 days (7 * 24 * 60 * 60 * 1000 ms) |
httpOnly: true means JavaScript running in the browser cannot read the cookie value. This protects tokens from XSS attacks.The
sameSite value is lax for OAuth callbacks to allow the redirect from the provider to carry the cookie. All other endpoints use strict.Token lifetimes
| Token | Lifetime | Controlled by |
|---|---|---|
| Access token | Typically 1 hour (Supabase default) | Supabase project settings |
| Refresh token | 7 days | Hard-coded cookie maxAge in the controller |
Refreshing tokens
When the access token expires, use the refresh token stored in therefreshToken cookie to get a new pair.
Request
curl
refreshToken cookie automatically — no request body is needed.
Response
accessToken and refreshToken cookies are written on success. The old tokens are replaced.
Error — missing or invalid refresh token
Validating tokens
POST /api/v1/auth/validate-token performs a combined validate-or-refresh operation. It is designed for frontend app startup checks where you want to confirm the session is still alive and silently refresh it if needed.
Logic (validateAndRefreshToken)
Request
curl
Authorization header:
curl
Response — token valid
Response — token refreshed
Frontend integration tips
On every page load, callPOST /validate-token with credentials: 'include'. Use tokenRefreshed to know whether a new access token was issued.
TypeScript
accessToken cookie is sent automatically by the browser. No manual token handling is required.
For protected routes that use the Authorization header (e.g., server-side rendering or non-browser clients), read the accessToken cookie and attach it as Bearer <token> in the Authorization header.
Error cases
| Scenario | HTTP status | Error |
|---|---|---|
| No tokens present | 401 | No tokens provided |
| Access token expired, no refresh token | 401 | Access token expired and no refresh token available |
| Refresh token invalid or expired | 401 | Refresh token invalid or expired. Please login again. |
| Unexpected server error | 500 | Token validation failed |