FridgeRadar uses JSON Web Tokens (JWT) for stateless authentication. Every protected endpoint requires anDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/EstefanoARG/FridgeRadar/llms.txt
Use this file to discover all available pages before exploring further.
Authorization: Bearer <token> header. The typical flow is straightforward: create an account with the registration endpoint, exchange your credentials for a token via the login endpoint, then attach that token to all future requests. Tokens are signed with HS256 using a server-side secret and expire after a configurable window (default 24 hours).
Registration and login flow
Register a new user account
Send a A successful registration returns
POST request to /api/v1/auth/register with a JSON body. The nombres field and correo (email) are required; apellidos is optional.201 Created with a UsuarioResponse body:| Field | Type | Description |
|---|---|---|
id_usuario | int | Auto-assigned primary key |
nombres | string | First name(s) |
apellidos | string | null | Last name(s) |
correo | string | Unique email address |
fecha_registro | datetime | null | Account creation timestamp |
estado | string | Account status (e.g. "activo") |
Log in and obtain an access token
The login endpoint uses OAuth2 password flow — credentials must be sent as A successful login returns a Store the
application/x-www-form-urlencoded form fields, not JSON. The username field must contain the user’s email address.TokenResponse:access_token securely — the React frontend keeps it in localStorage under the key "token".Token expiry
Tokens expire afterACCESS_TOKEN_EXPIRE_MINUTES minutes from the time they are issued. The default value is 1440 minutes (24 hours). Once a token expires, the user must log in again to obtain a fresh one. You can override the default by setting ACCESS_TOKEN_EXPIRE_MINUTES in your environment or .env file.
The JWT
sub claim contains the id_usuario integer, which the backend uses to identify the authenticated user on every protected route via get_current_user.Frontend Axios integration
The React frontend (Vite + Axios) centralises all token-handling infrontend/src/api/client.js. A request interceptor reads the token from localStorage and injects it into every outbound request automatically:
401 responses: if the server rejects a token (expired or invalid), the interceptor clears the stale token from localStorage and redirects the user to /login.
The auth.js helper wraps the two auth endpoints, using URLSearchParams to correctly encode the OAuth2 form body for login: