Authentication
API-ul InfoCalorii folosește JWT (JSON Web Tokens) pentru autentificare.
Login
POST /api/v1/login
Content-Type: application/json
Request Body:
{
"email": "user@example.com",
"password": "password123"
}
Response:
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"user": {
"id": 1,
"email": "user@example.com",
"name": "John Doe"
}
}
Using the Token
Includeți access_token în header-ul Authorization:
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Refresh Token
Access tokens expiră după 1 oră. Folosiți refresh token pentru a obține un nou access token:
POST /api/v1/refresh
Content-Type: application/json
Request Body:
{
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
Register
POST /api/v1/register
Content-Type: application/json
Request Body:
{
"email": "user@example.com",
"password": "password123",
"name": "John Doe"
}