GastroMóvil’s REST API uses two authentication mechanisms side-by-side: JWT Bearer tokens (viaDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/lffiesco-svg/gastromovil/llms.txt
Use this file to discover all available pages before exploring further.
djangorestframework-simplejwt) for programmatic API access, and Django session cookies for the server-rendered web UI. Both are listed in DEFAULT_AUTHENTICATION_CLASSES; the framework tries SessionAuthentication first, then falls back to JWTAuthentication. For API clients, JWT is the recommended approach.
JWT Configuration
The following settings govern token behavior in GastroMóvil:| Setting | Value |
|---|---|
ACCESS_TOKEN_LIFETIME | 60 minutes |
AUTH_HEADER_TYPES | Bearer |
Obtain Tokens
Send the user’s email address as theusername field together with the account password. GastroMóvil uses an EmailBackend, so the login identifier is always the email address even though the field is named username in the JWT payload.
POST /api/login/
The user’s email address. GastroMóvil’s
EmailBackend authenticates by email, not by a separate username string.The account password in plain text over HTTPS.
200 OK
Short-lived JWT access token. Valid for 60 minutes. Include this in the
Authorization header for every protected request.Long-lived JWT refresh token. Use it at
POST /api/refresh/ to obtain a new access token.401 Unauthorized
Use the Access Token
Add the access token as aBearer value in the Authorization header on every request that requires authentication.
Omitting the header or sending an expired token on a protected endpoint returns
401 Unauthorized with {"detail": "Authentication credentials were not provided."}.Refresh the Access Token
When the access token expires, exchange the refresh token for a new one without asking the user to log in again.POST /api/refresh/
The refresh token received from
POST /api/login/.200 OK
Django Session Authentication
The browser-facing web UI authenticates through Django’s standard session mechanism. A successfulPOST to POST /usuarios/login/ (form fields: email, password) creates a session cookie that the browser attaches automatically to subsequent requests.
Session cookies expire after 30 minutes of inactivity (SESSION_COOKIE_AGE = 1800) and are discarded when the browser tab is closed (SESSION_EXPIRE_AT_BROWSER_CLOSE = True).
Authentication Class Order
GastroMóvil’sREST_FRAMEWORK setting registers authentication backends in this order:
Authorization header. When there is no session, it looks for a Bearer token.
Ownership Requirement
Most restaurant-facing API endpoints enforce an additional ownership check beyond authentication. Resources are scoped to the currently authenticated user’s restaurant — for example, product and order queries are filtered byrestaurante__propietario=request.user. A valid token for a user who does not own the requested restaurant returns 404 Not Found, not 403 Forbidden.