generate_token
The generate_token method generates a temporary login token for a user. Tokens can be used in place of a password.
Note:The authenticate method can also be used to generate tokens.
Syntax
{
  <credentials object>
  "user": <mailbox_name>, 
  "reason": <text>,
  "token": <token>,
  "oma": <boolean>,
  "duration": <number of hours>, 
  "type": oma | session | sso
}Request fields for generate_token
Request fields for generate_token
Field name  | Obligation  | Definition/Value  | 
|---|---|---|
duration  | Optional  | The number of hours for which the token is valid. If this value is not specified, the token is valid for 24 hours.  | 
oma  | Optional  | If set to true, a session or sso type token may also be used with the OMA. If type = oma, this parameter is ignored. 
  | 
reason  | Required  | The reason that the token was generated.  | 
token  | Optional  | The token to add. If this value is not submitted, a random token is generated.  | 
type  | Optional  | The type of token to generate. 
 If type is not specified, session is used.  | 
user  | Required  | The user's mailbox name.  | 
Response fields for generate_token
The following fields may be returned in response to the generate_token
method:
Field name  | Obligation  | Description/Value  | 
|---|---|---|
duration  | Returned if success = true  | The number of hours for which the token is valid.  | 
error  | Returned if success = false  | A text string that explains the error.  | 
error_number  | Returned if success = false  | A number that represents the error.  | 
success  | Always returned  | Indicates whether the request was successful or not. Allowed values are true and false.  | 
token  | Returned if success = true  | The token that was generated.  | 
Examples for generate_token
Example 1
Adds an sso token with default duration.
Request
{
  "credentials": {
  	"user": "[email protected]",
    "password": "pencil75"
  },
  "user": "[email protected]",
  "type": "sso",
  "reason": "Login via portal"
}Response
{
"success": true,
"duration": 24,
"token": "d39b3ab55786e3a6161f860c3360107c",
}Example 2
Adds a specific session token with a 3 hour duration.
Request
{
  "credentials": {
    "user": "[email protected]",
    "password": "pencil75"
  },
  "user": "[email protected]",
  "reason": "User forgot password and needs temporary token to log in", 
  "token": "JaneTophatDishwasher",
  "duration": 3
}Response
{
  "success": true,
  "duration": 3,
  "token": "JaneTophatDishwasher",
}Updated 7 months ago
