curl --request POST \
--url https://api.example.com/api/auth/login \
--header 'Content-Type: application/json' \
--data '
{
"email": "<string>",
"password": "<string>"
}
'{
"message": "Invalid email or password"
}
Authenticate a user with email and password
curl --request POST \
--url https://api.example.com/api/auth/login \
--header 'Content-Type: application/json' \
--data '
{
"email": "<string>",
"password": "<string>"
}
'{
"message": "Invalid email or password"
}
{
"message": "User loggedIn successfully.",
"user": {
"id": "507f1f77bcf86cd799439011",
"username": "johndoe",
"email": "[email protected]"
}
}
token with a 1-day expiration. The token contains:
id: User’s unique identifierusername: User’s usernameexp: Token expiration timestamp{
"message": "Invalid email or password"
}
curl -X POST https://api.example.com/api/auth/login \
-H "Content-Type: application/json" \
-c cookies.txt \
-d '{
"email": "[email protected]",
"password": "securePassword123"
}'
JWT_SECRET environment variable