Skip to content

Password grant

POST /oauth/token issues the token through OAuth 2.0 password grant in a single call. Use this route in technical integrations, with an operator dedicated to the integration.

Important

/oauth/token only accepts native authentication: it does not apply 2FA and does not accept LDAP. To reproduce the Riversoft Console Portal sign-in, with 2FA or LDAP, use Local sign-in and 2FA.

Obtain the token

Send the operator credentials in an application/x-www-form-urlencoded form:

read -r -p 'Operator: ' API_USER
read -r -s -p 'Password: ' API_PASSWORD; printf '\n'

curl -s \
  --data-urlencode 'grant_type=password' \
  --data-urlencode "username=$API_USER" \
  --data-urlencode "password=$API_PASSWORD" \
  "$API_BASE/oauth/token"

Response

{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "scope": "{\"stcpcore\":{\"instance\":15,\"user\":15,\"service\":15,\"schedule\":15,...}}",
  "operator": "stcpadmin",
  "rest_name": "RestAPI",
  "token_type": "Bearer"
}
FieldDescription
access_tokenToken used in the following calls.
scopeOperator permissions on each resource group (JSON serialized as text).
operatorAuthenticated operator.
rest_nameAPI registration name (rest_name in config.json).
token_typeAlways Bearer.

The token is valid for 60 minutes by default. See how to use it in Session and logout.

Errors

HTTPSituation
400grant_type other than password, missing username or password, or empty body.
401Credentials not accepted or operator locked (Operator is locked, contact your system administrator).
415Content-Type other than application/x-www-form-urlencoded.
500Internal error.

After the maximum number of failures set in the password policies, the operator is locked.

Full contract in Reference: Authentication.