Add a Token
1. API Description
This API is used to add a token for a user.
Request mode: POST [ip]/api/user/token-add
| Administrator Rights | Logged-in |
|---|---|
| No | Yes |
2. Input Parameters
| Name | Required | Type | Description |
|---|---|---|---|
| username | Yes | String | The user name |
| token | Yes | String | Token |
| expire | Yes | Int | Token expiration time, starting from 1970-01-01 00:00:00 +0000 (UTC), in seconds. -1 means unlimited. |
3. Output Parameters
| Name | Type | Description |
|---|---|---|
| status | Int | Status code |
| code | String | Status description |
4. Example
Adding a Token.
Input Example
{
"username":"Admin",
"token":"HTrkbOUWh3KCl57aYmSLHT3qDyswncF4ynAGJatr8i5laiZZbUT83MnhRJOlghFB",
"expire": -1
}
Output Example
{
"status": 0,
"code": "Success"
}
5. Error Code
The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.
| Status | Definition | Description |
|---|---|---|
| 7 | MW_STATUS_INVALID_ARG | Missing required parameters |
| 31 | NOT_PERMITTED | Only administrators have permission |
| 41 | CONSTRAINT_VIOLATION | The existed user |