token.get

Description

integer/array token.get(object parameters)

The method allows to retrieve tokens according to the given parameters.

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

Parameters

(object) Parameters defining the desired output.

The method supports the following parameters.

ParameterTypeDescription
tokenidsstring/arrayReturn only tokens with the given IDs.
useridsstring/arrayReturn only tokens created for the given users.
tokenstringReturn only tokens created for the given Auth token.
valid_attimestampReturn only tokens which are valid (not expired) at the given date and time.
expired_attimestampReturn only tokens which are expired (not valid) at the given date and time.
sortfieldstring/arraySort the result by the given properties.

Possible values are: tokenid, name, lastaccess, status, expires_at and created_at.
countOutputbooleanThese parameters being common for all get methods are described in detail in the reference commentary.
excludeSearchboolean
filterobject
limitinteger
outputquery
preservekeysboolean
searchobject
searchByAnyboolean
searchWildcardsEnabledboolean
sortorderstring/array
startSearchboolean

Return values

(integer/array) Returns either:

  • an array of objects;
  • the count of retrieved objects, if the countOutput parameter has been used.

Examples

Retrieve an token

Retrieve all data for token with ID “2”.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "token.get",
  4. "params": {
  5. "output": "extend",
  6. "tokenids": "2"
  7. },
  8. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  9. "id": 1
  10. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "tokenid": "1",
  6. "name": "The Token",
  7. "description": "",
  8. "userid": "1",
  9. "lastaccess": "0",
  10. "status": "0",
  11. "expires_at": "1609406220",
  12. "created_at": "1611239454",
  13. "creator_userid": "1"
  14. }
  15. ],
  16. "id": 1
  17. }

Source

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