curl --request POST \
--url https://api.example.com/auth/login \
--header 'Content-Type: application/json' \
--data '
{
"email": "<string>",
"password": "<string>"
}
'{
"access_token": "<string>",
"token_type": "<string>",
"user": {
"id": 123,
"name": "<string>",
"email": "<string>"
}
}Authenticate and receive an access token
curl --request POST \
--url https://api.example.com/auth/login \
--header 'Content-Type: application/json' \
--data '
{
"email": "<string>",
"password": "<string>"
}
'{
"access_token": "<string>",
"token_type": "<string>",
"user": {
"id": 123,
"name": "<string>",
"email": "<string>"
}
}POST /auth/login
"john.doe@example.com""SecurePass123"Authorization header for subsequent requests.Example: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJqb2huLmRvZUBleGFtcGxlLmNvbSIsImV4cCI6MTcwOTU1MTIwMH0.abc123""bearer".curl -X POST "https://api.smarteat.ai/auth/login" \
-H "Content-Type: application/json" \
-d '{
"email": "john.doe@example.com",
"password": "SecurePass123"
}'
const response = await fetch('https://api.smarteat.ai/auth/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: 'john.doe@example.com',
password: 'SecurePass123'
})
});
const data = await response.json();
console.log(data.access_token);
// Store the token for subsequent requests
localStorage.setItem('access_token', data.access_token);
import requests
response = requests.post(
'https://api.smarteat.ai/auth/login',
json={
'email': 'john.doe@example.com',
'password': 'SecurePass123'
}
)
data = response.json()
print(data['access_token'])
# Store the token for subsequent requests
access_token = data['access_token']
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJqb2huLmRvZUBleGFtcGxlLmNvbSIsImV4cCI6MTcwOTU1MTIwMH0.abc123def456",
"token_type": "bearer",
"user": {
"id": 1,
"name": "John Doe",
"email": "john.doe@example.com"
}
}
{
"detail": "Invalid email or password"
}
{
"detail": [
{
"type": "missing",
"loc": ["body", "email"],
"msg": "Field required",
"input": {"password": "SecurePass123"}
}
]
}
{
"detail": [
{
"type": "value_error",
"loc": ["body", "email"],
"msg": "value is not a valid email address",
"input": "not-an-email"
}
]
}
{
"detail": "Error during authentication"
}
Authorization header for authenticated requests:
curl -X GET "https://api.smarteat.ai/auth/me" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
401 Unauthorized response and must login again to obtain a new token.