Authentications
sign in
Authenticate a user and retrieve a JWT token.
Endpoint
Request
Headers
Name | Required | Description |
---|---|---|
Content-Type | Yes | application/json |
Body
Field | Type | Required | Description |
---|---|---|---|
string | Yes | User’s email | |
password | string | Yes | User’s password |
Response
Success Response
Code: 200 OK
Content example:
Field | Type | Description |
---|---|---|
token | string | JWT token for authenticated sessions |
Error Response
Code: 401 UNAUTHORIZED
Content example:
Notes
- The endpoint uses Passport’s local strategy for authentication.
- Upon successful authentication, a JWT token is returned which should be used for subsequent authenticated requests.
- The token contains encoded user information and has an expiration time.
Example Usage
JavaScript (Fetch API)
Security Considerations
- Always use HTTPS to prevent interception of credentials.
- Implement rate limiting to prevent brute-force attacks.
- Consider adding additional security measures like 2FA for sensitive operations.
- Store the JWT securely (e.g., in HttpOnly cookies) to prevent XSS attacks.
- Implement CSRF protection if using cookies for token storage.