GuidesAuthentication

Login/Password

It is possible to login to Mist API using email/password combination. If the user has Two-Factor Authentication (2FA) enabled, the user needs to provide the 2FA token as well.
Once logged in, a session cookie is created and must be used for subsequent API calls.

Login with Email/Password

POST /api/v1/login

Example

{
    "email": "test@mistsys.com",
    "password": "foryoureyesonly"
}

Parameter

NameTypeDescription
emailstringRequired.
passwordstringRequired.

Response if login successfully (i.e. email/password matches)

Status: 200 OK
Set-Cookie: csrftoken=vwvBuq9qkqaKh7lu8tNc0gkvBfEaLAmx; expires=Tue, 15-Mar-2016 19:47:20 GMT; Max-Age=31449600; Path=/

Response if login failed

Status: 400 Bad Request

{
    "detail": "sso admin login needs to be initiated by IdP",
    "forward_url": "https://my.sso/idp_sso_url"
}

Login with 2FA

When 2FA is enabled, there are two ways to login. 1. login with two_factor token (with Google Authenticator, etc) 2. login with email/password, SMS the token, and use /login/two_factor with the token

POST /api/v1/login

Example

{
    "email": "test@mistsys.com",
    "password": "foryoureyesonly",
    "two_factor": "123456"
}

Parameter

NameTypeDescription
emailstringRequired.
passwordstringRequired.
two_factorstringif two-factor authentication is enabled, this can be used to skip a separate call to /login/two_factor

Response if login successfully (i.e. email/password/two_factor matches)

Status: 200 OK
Set-Cookie: csrftoken=vwvBuq9qkqaKh7lu8tNc0gkvBfEaLAmx; expires=Tue, 15-Mar-2016 19:47:20 GMT; Max-Age=31449600; Path=/

Response if login failed

Status: 400 Bad Request

Response if email/password matches but two_factor doesn’t match

The session is partially created, /self reflects the pending two_factor authentication. Use /login/two_factor to login fully

Status: 401 Unauthorized
Set-Cookie: csrftoken=vwvBuq9qkqaKh7lu8tNc0gkvBfEaLAmx; expires=Tue, 15-Mar-2016 19:47:20 GMT; Max-Age=31449600; Path=/

Response if email/password matches but two_factor is not provided

The session is partially created, /self reflects the pending two_factor authentication. Use /login/two_factor to login fully

Status: 200 OK
Set-Cookie: csrftoken=vwvBuq9qkqaKh7lu8tNc0gkvBfEaLAmx; expires=Tue, 15-Mar-2016 19:47:20 GMT; Max-Age=31449600; Path=/

Perform Two-Factor Authentication

POST /api/v1/login/two_factor

Request

{
    "two_factor": "123456"
}

Response if provided two_factor code is correct

Status: 200 OK
Set-Cookie: csrftoken=vwvBuq9qkqaKh7lu8tNc0gkvBfEaLAmx; expires=Tue, 15-Mar-2016 19:47:20 GMT; Max-Age=31449600; Path=/

Response if provided two_factor code is incorrect

Status: 401 Unauthorized

Response if the user hasn’t login yet

Status: 401 Unauthorized

Response if the user doesn’t have 2FA enabled

Status 404 Not Found

On this page