Log in a user and get authentication tokens. The email field accepts the email address or the desktop login of the user. Desktop tools that do not know the email address use the desktop login. If the user has two-factor authentication, give one second factor. The organisation has the chat tokens only for an administrator.
Responses
-
The login is successful. If the instance enforces two-factor authentication and the user has not set it up, the body has two_factor_authentication_required and the tokens only give access to the authentication routes until the setup is done.
-
The login failed. The body tells the cause with the flags default_password, missing_OTP, wrong_OTP or too_many_failed_login_attemps. A wrong email and a wrong password give the same answer.
-
The user is inactive. The body has the flag unactive.
-
The authentication strategy is not correctly configured
-
The database is not available, or a server error occurred
curl -X POST "http://api.example.com/auth/login" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"email": "admin@example.com",
"password": "mysecretpassword",
"totp": 123456,
"email_otp": 123456,
"fido_authentication_response": {},
"recovery_code": "ABCD-EFGH-IJKL-MNOP"
}'
import requests
url = "http://api.example.com/auth/login"
headers = {
"Authorization": "Bearer YOUR_API_TOKEN",
"Accept": "application/json",
"Content-Type": "application/json"
}
params = {}
payload = {
"email": "admin@example.com",
"password": "mysecretpassword",
"totp": 123456,
"email_otp": 123456,
"fido_authentication_response": {},
"recovery_code": "ABCD-EFGH-IJKL-MNOP"
}
response = requests.post(
url,
headers=headers,
params=params,
json=payload
)
response.raise_for_status()
if response.content:
print(response.json())
{
"email": "admin@example.com",
"password": "********",
"totp": "123456",
"email_otp": "123456",
"fido_authentication_response": {},
"recovery_code": "ABCD-EFGH-IJKL-MNOP"
}