This is a translation of the original English documentation page. Help us make it better.

token.create

Description

object token.create(object/array tokens)

This method allows to create new tokens.

Only Super admin user type is allowed to manage tokens for other users.

A token created by this method has to be generated before it is usable.

Parametri

(object/array) Token da creare.

Il metodo accetta token con proprietà token standard.

Valori di ritorno

(object) Restituisce un oggetto contenente gli ID dei token creati sotto la proprietà tokenids. L'ordine degli ID restituiti corrisponde all'ordine dei token passati.

Esempi

Create a token

Create an enabled token that never expires and authenticates user of ID 2.

Request:

{
           "jsonrpc": "2.0",
           "method": "token.create",
           "params": {
               "name": "Your token",
               "userid": "2"
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "tokenids": [
                   "188"
               ]
           },
           "id": 1
       }

Create a disabled token that expires at January 21st, 2021. This token will authenticate current user.

Request:

{
           "jsonrpc": "2.0",
           "method": "token.create",
           "params": {
               "name": "Your token",
               "status": "1",
               "expires_at": "1611238072"
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "tokenids": [
                   "189"
               ]
           },
           "id": 1
       }

Fonte

CToken::create() in ui/include/classes/api/services/CToken.php.