token.generate

Description

object token.generate(array tokenids)

This method allows to generate tokens.

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

Parameters

(array) IDs of the tokens to generate.

Return values

(array) Returns an array of objects containing the ID of the generated token under the tokenid property and generated authorization string under token property.

PropertyTypeDescription
tokenidstringID of the token.
tokenstringThe generated authorization string for this token.

Examples

Generate multiple tokens

Generate two tokens.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "token.generate",
  4. "params": [
  5. "1",
  6. "2"
  7. ],
  8. "auth": "3a57200802b24cda67c4e4010b50c065",
  9. "id": 1
  10. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "tokenid": "1",
  6. "token": "bbcfce79a2d95037502f7e9a534906d3466c9a1484beb6ea0f4e7be28e8b8ce2"
  7. },
  8. {
  9. "tokenid": "2",
  10. "token": "fa1258a83d518eabd87698a96bd7f07e5a6ae8aeb8463cae33d50b91dd21bd6d"
  11. }
  12. ],
  13. "id": 0
  14. }

Source

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