Overview
The DADDO API uses JWT (JSON Web Token) based authentication. After successful login, you receive a token that must be included in subsequent API requests.Token Storage
Tokens can be stored in either:- localStorage - For persistent sessions (“Remember Me”)
- sessionStorage - For temporary sessions
rememberMe parameter during login.
Automatic Token Injection
Tokens are automatically included in API requests via an Axios interceptor:How to Authenticate
Step 1: Register or Login
First, create an account or login to receive an authentication token.Step 2: Store the Token
Successful authentication returns:Step 3: Include Token in Requests
Include the token in the Authorization header:Token Expiration
Automatic Logout on Expiration
When a token expires, the API returns a401 Unauthorized response. The system automatically:
- Detects the 401 status via response interceptor
- Checks if a token exists in storage
- If token exists (meaning it expired), clears all auth data:
- Removes token from localStorage
- Removes token from sessionStorage
- Removes user data from storage
- Dispatches logout action to Redux store
Handling Expired Tokens
Your application should:- Listen for logout actions
- Redirect users to the login page
- Prompt for re-authentication
Token Refresh
Currently, the API does not support token refresh. Users must re-authenticate when tokens expire.
Security Best Practices
Store tokens securely
Store tokens securely
- Never expose tokens in URLs or logs
- Use HTTPS for all API requests
- Clear tokens on logout
Handle token expiration gracefully
Handle token expiration gracefully
- Implement automatic logout on 401 responses
- Clear all stored authentication data
- Redirect to login page
Use appropriate storage
Use appropriate storage
- Use sessionStorage for temporary sessions
- Use localStorage only when “Remember Me” is enabled
- Never store tokens in cookies without HttpOnly flag
Authentication Errors
401 Unauthorized
Returned when:- No token is provided
- Token is invalid or malformed
- Token has expired
403 Forbidden
Returned when:- Token is valid but user lacks permission
- Resource access is restricted
Example: Full Authentication Flow
Next Steps
Auth Endpoints
Explore authentication endpoints
Products API
Start working with products