manual:api:reference:token:get

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

manual:api:reference:token:get [2021/01/27 21:18] (current)
Line 1: Line 1:
 +===== token.get =====
  
 +==== Description ====
 +
 +''​integer/​array token.get(object **parameters**)''​
 +
 +The method allows to retrieve tokens according to the given parameters.
 +
 +<​note>​Only //Super admin// user type is allowed to view tokens for other users.</​note>​
 +
 +==== Parameters ====
 +
 +''​(object)''​ Parameters defining the desired output.
 +
 +The method supports the following parameters.
 +
 +^ Parameter ^ [[:​manual/​api/​reference_commentary#​data_types|Type]] ^ Description ^
 +| tokenids | string/​array | Return only tokens with the given IDs. |
 +| userids | string/​array | Return only tokens created for the given users. |
 +| token | string | Return only tokens created for the given //Auth token//. |
 +| valid_at | timestamp | Return only tokens which are valid (not expired) at the given date and time. |
 +| expired_at | timestamp | Return only tokens which are expired (not valid) at the given date and time. |
 +^ |||
 +| sortfield | string/​array | Sort the result by the given properties. \\ \\ Possible values are: ''​tokenid'',​ ''​name'',​ ''​lastaccess'',​ ''​status'',​ ''​expires_at''​ and ''​created_at''​. |
 +| countOutput |boolean|These parameters being common for all ''​get''​ methods are described in detail in the [[manual:​api:​reference_commentary#​common_get_method_parameters|reference commentary]]. ​ |
 +| excludeSearch |boolean|:::​|
 +| filter | object |:::|
 +| limit |integer|:::​|
 +| output |query|:::|
 +| preservekeys |boolean|:::​|
 +| search | object |:::|
 +| searchByAny |boolean|:::​|
 +| searchWildcardsEnabled |boolean|:::​|
 +| sortorder | string/​array | ::: |
 +| startSearch |boolean|:::​|
 +
 +==== 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:
 +<code java>
 +{
 +    "​jsonrpc":​ "​2.0",​
 +    "​method":​ "​token.get",​
 +    "​params":​ {
 +        "​output":​ "​extend",​
 +        "​tokenids":​ "​2"​
 +    },
 +    "​auth":​ "​038e1d7b1735c6a5436ee9eae095879e",​
 +    "​id":​ 1
 +}
 +</​code>​
 +
 +Response:
 +<code java>
 +{
 +    "​jsonrpc":​ "​2.0",​
 +    "​result":​ [
 +        {
 +            "​tokenid":​ "​1",​
 +            "​name":​ "The Token",​
 +            "​description":​ "",​
 +            "​userid":​ "​1",​
 +            "​lastaccess":​ "​0",​
 +            "​status":​ "​0",​
 +            "​expires_at":​ "​1609406220",​
 +            "​created_at":​ "​1611239454",​
 +            "​creator_userid":​ "​1"​
 +        }
 +    ],
 +    "​id":​ 1
 +}
 +</​code>​
 +
 +==== Source ====
 +
 +CToken::​get() in //​ui/​include/​classes/​api/​services/​CToken.php//​.