Authentication
User Login
Login and token refresh using OAuth2 token endpoint
POST
OAuth2 token endpoint supporting password grant (login) and refresh token grant. This endpoint authenticates users and returns access tokens for API access.
Example authenticated request:
Password Grant (Login)
Authenticate a user with email/phone and password to receive access and refresh tokens.Query Parameters
The OAuth2 grant type. Use
password for login or refresh_token for token refresh.Request Body (Password Grant)
User’s email address. Either email or phone is required.
User’s phone number in international format. Either email or phone is required.
User’s password.
Refresh Token Grant
Use a refresh token to obtain new access tokens without re-authentication.Request Body (Refresh Token Grant)
The refresh token obtained from a previous authentication.
Response
JWT access token for authenticating API requests
Token type, always “bearer”
Token expiration time in seconds (typically 3600 for 1 hour)
Token expiration timestamp (Unix timestamp)
Refresh token for obtaining new access tokens
User information object
Error Responses
Using Access Tokens
Include the access token in the Authorization header for authenticated requests:Token Refresh Strategy
Implement automatic token refresh in your application:Phone Number Login
To login with a phone number instead of email:Rate Limiting
This endpoint is rate limited to prevent brute force attacks:- Password Grant: 5 attempts per minute per IP address
- Refresh Token Grant: 10 requests per minute per user
Security Features
- Secure Password Hashing: Passwords are verified using bcrypt
- Token Rotation: Refresh tokens are rotated on each use
- Rate Limiting: Protection against brute force attacks
- Audit Logging: All authentication attempts are logged
Next Steps
After successful authentication:- Store tokens securely - Save access and refresh tokens
- Make authenticated requests - Use the access token in API calls
- Handle token expiration - Implement automatic refresh logic
- Implement logout - Use the logout endpoint