Create temporary token for a user
Creates a new temporary token for specific user. Temporary tokens must be confined with a time caveat and are not persisted (cannot be retrieved, listed, revoked, updated or deleted). However, it is possible to revoke all existing temporary tokens of the user: see more).
In case of invite tokens, invite / add member privileges are required in
the target entity to create a token. For example, space_add_group in
the space when creating a groupJoinSpace invite token.
This operation is available for the currently authorized user,
otherwise requires oz_tokens_manage admin privilege.
You can learn more about named and temporary tokens here.
Example cURL requests
Create temporary token for a user
curl -u username:password -X POST \
-d '{"type": {"accessToken":{}}, "caveats": [{"type": "time", "validUntil": 1571147494}]}' \
-H 'Content-type: application/json' \
https://$HOST/api/v3/onezone/users/$USER_ID/tokens/temporary
Path parameters
| Parameter | Type & Description |
|---|---|
| id required | string User Id |
Request body
Properties of the new temporary token.
| Property | Type & Description | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
type object (TokenPropertyTokenType) The type of the token (object) Enum: {accessToken: {}}{identityToken: {}}{inviteToken: {"...": "..."}}
| |||||||||||||||||||||||||||||||||||||||
caveats array of objects (Caveat) A list of caveats that confine the token.
| |||||||||||||||||||||||||||||||||||||||
Request Examples
{
"type": {
"inviteToken": {
"inviteType": "userJoinCluster",
"clusterId": "fb73f7ceff5abd995357abbe01c812ce"
}
},
"caveats": [
{
"type": "time",
"validUntil": 1571147494
},
{
"type": "ip",
"whitelist": [
"189.34.15.0/8",
"127.0.0.0/24",
"167.73.12.17"
]
}
]
}Responses
Returns the newly created temporary token in serialized form.
| Property | Type & Description |
|---|---|
token string (SerializedToken) The token in serialized form. | |
Invalid request.
| Property | Type & Description | ||||||
|---|---|---|---|---|---|---|---|
error object Object describing an error.
| |||||||
Example
{
"error": {
"id": "badValueString",
"details": {
"key": "name"
},
"description": "Bad value: provided \"name\" must be a string."
}
}Authentication error.
| Property | Type & Description | ||||||
|---|---|---|---|---|---|---|---|
error object Object describing an error.
| |||||||
Example
{
"error": {
"id": "badValueString",
"details": {
"key": "name"
},
"description": "Bad value: provided \"name\" must be a string."
}
}Authorization error.
| Property | Type & Description | ||||||
|---|---|---|---|---|---|---|---|
error object Object describing an error.
| |||||||
Example
{
"error": {
"id": "badValueString",
"details": {
"key": "name"
},
"description": "Bad value: provided \"name\" must be a string."
}
}Resource not found.
| Property | Type & Description | ||||||
|---|---|---|---|---|---|---|---|
error object Object describing an error.
| |||||||
Example
{
"error": {
"id": "badValueString",
"details": {
"key": "name"
},
"description": "Bad value: provided \"name\" must be a string."
}
}Internal server Error.
| Property | Type & Description | ||||||
|---|---|---|---|---|---|---|---|
error object Object describing an error.
| |||||||
Example
{
"error": {
"id": "badValueString",
"details": {
"key": "name"
},
"description": "Bad value: provided \"name\" must be a string."
}
}