Authentication Flow
The API implements a token-based authentication system where:- Users register and create an account
- Users obtain access and refresh tokens by providing credentials
- Access tokens are used to authenticate API requests
- Refresh tokens are used to obtain new access tokens when they expire
All authenticated endpoints require the
Authorization header with a Bearer token.Token Lifecycle
Tokens have the following configuration:| Token Type | Lifetime | Purpose |
|---|---|---|
| Access Token | 1 hour | Authenticate API requests |
| Refresh Token | 3 days | Obtain new access tokens |
These settings are configured in
config/settings.py:208-214 using the SIMPLE_JWT configuration.Authentication Header Format
All authenticated requests must include the Authorization header:Default Permission Policy
The API usesIsAuthenticated as the default permission class for all endpoints:
AllowAny permission.
Public Endpoints
The following endpoints are publicly accessible without authentication:POST /api/v1/customers/- Customer registrationPOST /auth/token/- Obtain JWT tokensPOST /auth/token/refresh/- Refresh access token- Catalogue/product browsing endpoints
Custom User Model
The API uses a custom user model (Customer) that extends Django’s AbstractUser:
- Email is used as the primary identifier (not username)
- Required fields:
email,first_name,last_name - Additional customer-specific fields like purchase history and addresses
Next Steps
Registration
Learn how to create customer accounts
Token Management
Obtain, refresh, and manage JWT tokens
Permissions
Understand permission classes and access control