content/operate/rs/references/rest-api/requests/users/authorize.md
| Method | Path | Description |
|---|---|---|
| POST | /v1/users/authorize | Generate a token to authorize an authenticated user |
POST /v1/users/authorize
Generates a JSON Web Token (JWT) for a user to use as authorization to access the REST API. The request authentication header must include the relevant username and password.
POST /v1/users/authorize
The request body is optional unless you want to specify the token's time to live:
{
"ttl": <time_in_seconds>
}
| Key | Value | Description |
|---|---|---|
| Host | cnm.cluster.fqdn | Domain name |
| Accept | application/json | Accepted media type |
Optionally include a JSON object in the request body to specify the time to live (ttl), which determines the amount of time in seconds the token will be valid. The default ttl is 300 seconds. The minimum ttl is 1 second and the maximum ttl is 86400 seconds.
Returns a JSON object that contains the generated access token.
{
"access_token": "eyJ5bGciOiKIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXViOjE0NjU0..."
}
When errors are reported, the server may return a JSON object with
error_code and message fields that provide additional information.
The following are possible error_code values:
| Code | Description |
|---|---|
| password_expired | The password has expired and must be changed. |
| Code | Description |
|---|---|
| 200 OK | The user is authorized. |
| 400 Bad Request | The request could not be understood by the server due to malformed syntax. |
| 401 Unauthorized | The user is unauthorized. |