Skip to main content
The authentication system uses JWT (JSON Web Tokens) to secure API endpoints. Obtain an access token by logging in with valid credentials.
Test credentials: username admin, password admin123

POST /auth/login

curl -X POST http://localhost:8000/auth/login \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "username=admin&password=admin123"
Authenticate a user and receive a JWT access token.
username
string
required
The username for authentication
password
string
required
The user’s password

Response

access_token
string
JWT access token for authenticating subsequent API requests
token_type
string
The token type, always “bearer”
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "token_type": "bearer"
}

Error responses

{
  "detail": "Usuario o contraseña incorrectos"
}

Using the access token

Once you have obtained an access token, include it in the Authorization header for authenticated requests:
curl -X POST http://localhost:8000/products/ \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "Product name", "description": "Description", "category": "Category"}'
Access tokens expire after a configured time period. When a token expires, you’ll receive a 401 Unauthorized response and need to obtain a new token by logging in again.

Build docs developers (and LLMs) love