Skip to content

Authentication

Related guides: Local sign-in and 2FA, Password grant, Single Sign-On and Session and logout.

Errors of the authentication routes are returned in JSON, with error and error_description.

POST /oauth/token

Issues the access token through OAuth 2.0 password grant, with native authentication only. Does not apply 2FA and does not accept LDAP.

Access: public.

HeaderValue
Content-Typeapplication/x-www-form-urlencoded, exactly
Field (form)TypeRequiredDescription
grant_typestringYesAlways password.
usernamestringYesOperator.
passwordstringYesOperator password.

200 response

FieldDescription
access_tokenAccess token for the following calls.
scopeOperator permissions (JSON serialized as text).
operatorAuthenticated operator.
rest_nameAPI registration name.
token_typeBearer.

Responses

HTTPMeaning
200Token issued.
400Missing parameters (username, password), grant_type other than password or empty body.
401Credentials not accepted or operator locked after exceeding the failure limit of the password policies.
415Content-Type other than application/x-www-form-urlencoded.
500Internal error.

The token is valid for 60 minutes by default, or for the time set in session_duration in the API config.json (maximum 720 minutes).

POST /oauth/token HTTP/1.1
Host: api.example.com:33070
Content-Type: application/x-www-form-urlencoded

grant_type=password&username=<operator>&password=<password>

POST /oauth/v2/token

First step of the sign-in, with 2FA and LDAP. Receives the same form as POST /oauth/token. For LDAP, send username in the <provider>/<operator> format, with the name of the LDAP provider registered in ssoProviders.

Access: public.

Situation200 response
2FA disabledThe token, in the same format as POST /oauth/token.
2FA enabled, TOTP registeredURL: challenge path (/oauth/v2/token/mfa/{challengeID}).
2FA enabled, first accessURL, secret (TOTP secret in Base32) and qrcode (200 × 200 PNG in standard Base64). The secret is already stored.

Error responses are the same as POST /oauth/token.

POST /oauth/v2/token/mfa/{challengeID}

Second step of the sign-in with 2FA. Send the 6-digit code generated by the authenticator app.

Access: public.

HeaderValue
Content-Typeapplication/json, exactly
Field (JSON)TypeRequiredDescription
CodestringYesTOTP code.
OperatorstringNoIgnored: the API uses the challenge operator.

Responses

HTTPMeaning
200Valid code. The body brings the token, in the same format as POST /oauth/token.
400Empty body, invalid JSON or Content-Type other than application/json.
401Invalid code (Invalid code), nonexistent challenge (You need to authenticate first at /oauth/token) or operator locked on the fourth wrong code.
500Internal error.
POST /oauth/v2/token/mfa/<challengeID> HTTP/1.1
Host: api.example.com:33070
Content-Type: application/json

{"Code": "123456"}

Single Sign-On

Routes available when there are SSO providers in the API registration. They are public and used by the browser.

Method and routeCalled byDescription
GET /auth/api/v1/sso/login?provider=<name>BrowserStarts the sign-in. Responds 307 to the provider (saml2 and oauth2 only), or 400 in text with an invalid provider.
POST /auth/api/v1/sso/saml2/acsSAML 2.0 providerReceives SAMLResponse and RelayState.
GET /auth/api/v1/sso/oauth2OAuth 2.0 providerReceives code and state.
POST /auth/api/v1/sso/saml2/sloSAML 2.0 providerCompletes the federated logout and redirects (303) to the final destination.

The sign-in returns redirect (303) to sso_login_redirect with token, token_type (Bearer) and scope (permissions as Base64-encoded JSON) in the query string. On failure, with the error parameter.

DELETE /disconnect/api/v3/logout

Ends the session and invalidates the token.

Access: Bearer.

HeaderValue
AuthorizationBearer <access_token>
Acceptapplication/json

200 response

FieldTypeDescription
datastringOperation result (Logout successful).
redirectstringLogout address at the identity provider. Present only with sso_logout_end_session enabled and an SSO session.

Responses

HTTPMeaning
200Session ended.
401Missing or invalid token.
500Internal error.