Create named token for a user
Creates a new named token for specific user. The token name must be unique for the user.
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 token owner (subject),
otherwise requires oz_tokens_manage admin privilege.
You can learn more about named and temporary tokens here.
Example cURL requests
Create named token for a user
curl -u username:password -X POST -d '{"name": "new-token-1"}' \
-H 'Content-type: application/json' \
https://$HOST/api/v3/onezone/users/$USER_ID/tokens/named
Path parameters
| Parameter | Type & Description |
|---|---|
| id required | string User Id |
Request body
Properties of the new named token.
| Property | Type & Description | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name string (TokenPropertyName) Token name (unique for subject user/provider) | |||||||||||||||||||||||||||||||||||||||
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.
| |||||||||||||||||||||||||||||||||||||||
customMetadata object (TokenPropertyCustomMetadata) Arbitrary user metadata (JSON) attached to the token | |||||||||||||||||||||||||||||||||||||||
revoked boolean (TokenPropertyRevoked) Determines if this token is revoked (cannot be used) - can be toggled at will | |||||||||||||||||||||||||||||||||||||||
privileges array of strings A list of privileges that will be granted to the user that consumes the invite token. NOTE that this parameter is recognized only if the token type is invite token and the invitation target supports member privileges. The privileges must be valid for given invite token type (for example, group privileges for | |||||||||||||||||||||||||||||||||||||||
usageLimit integer (InviteTokenPropertyUsageLimit) Usage limit for an invite token (positive integer) or | |||||||||||||||||||||||||||||||||||||||
Request Examples
{
"name": "New Token",
"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"
]
}
],
"customMetadata": {
"jobName": "experiment-15",
"vm": "worker156.cloud.local"
},
"revoked": false,
"privileges": [
"cluster_view",
"cluster_update",
"cluster_delete",
"cluster_view_privileges",
"cluster_set_privileges"
],
"usageLimit": 15
}Responses
Response body contains the Id of newly created named token and its serialized form. Additionally, URI of the created named token in form https://$HOST/api/onezone/v3/tokens/named/{id} is returned in the response Location header.
| Property | Type & Description |
|---|---|
tokenId string (TokenPropertyId) Unique identifier of the token | |
token string (SerializedToken) The token in serialized form. | |
Example
{
"tokenId": "2b5d0dd5aa6443a69277b5ce0544fec2",
"token": "MDAxNWxvY2F0aW9uIG9uZXpvbmUKMDAzYmlkZW50aWZpZXIgOEhmSEFSSGdrbHFCa1pWSTR"
}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."
}
}