tokens
Creates, updates, deletes, gets or lists a tokens resource.
Overview
| Name | tokens |
| Type | Resource |
| Id | databricks_workspace.settings.tokens |
Fields
The following fields are returned by SELECT queries:
- list
| Name | Datatype | Description |
|---|---|---|
token_id | string | The ID of this token. |
autoscope_state | string | |
backfill_scopes | array | Output only. Scopes inferred from offline backfill processing. |
comment | string | Comment the token was created with, if applicable. |
creation_time | integer | Server time (in epoch milliseconds) when the token was created. |
expiry_time | integer | Server time (in epoch milliseconds) when the token will expire, or -1 if not applicable. |
inferred_scopes | array | Output only. Inferred API path scopes collected for this token when autoscope is enabled. |
last_accessed_time | integer | Server time (in epoch milliseconds) when the token was accessed most recently. |
scopes | array | Scope of the token was created with, if applicable. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
list | select | deployment_name | Lists all the valid tokens for a user-workspace pair. | |
create | insert | deployment_name | Creates and returns a token for a user. If this call is made through token authentication, it creates | |
tokens_update | update | token_id, deployment_name, token, update_mask | Updates the comment or scopes of a token. | |
delete | exec | deployment_name, token_id | Revokes an access token. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
deployment_name | string | The Databricks Workspace Deployment Name (default: dbc-abcd0123-a1bc) |
token_id | string | The SHA-256 hash of the token to be updated. |
SELECT examples
- list
Lists all the valid tokens for a user-workspace pair.
SELECT
token_id,
autoscope_state,
backfill_scopes,
comment,
creation_time,
expiry_time,
inferred_scopes,
last_accessed_time,
scopes
FROM databricks_workspace.settings.tokens
WHERE deployment_name = '{{ deployment_name }}' -- required
;
INSERT examples
- create
- Manifest
Creates and returns a token for a user. If this call is made through token authentication, it creates
INSERT INTO databricks_workspace.settings.tokens (
autoscope_enabled,
comment,
lifetime_seconds,
scopes,
deployment_name
)
SELECT
{{ autoscope_enabled }},
'{{ comment }}',
{{ lifetime_seconds }},
'{{ scopes }}',
'{{ deployment_name }}'
RETURNING
token_info,
token_value
;
# Description fields are for documentation purposes
- name: tokens
props:
- name: deployment_name
value: "{{ deployment_name }}"
description: Required parameter for the tokens resource.
- name: autoscope_enabled
value: {{ autoscope_enabled }}
description: |
Whether to enable autoscoping for this token. When true, the token will automatically collect inferred API path scopes as it is used.
- name: comment
value: "{{ comment }}"
description: |
Optional description to attach to the token.
- name: lifetime_seconds
value: {{ lifetime_seconds }}
description: |
The lifetime of the token, in seconds. If the lifetime is not specified, this token remains valid for 2 years.
- name: scopes
value:
- "{{ scopes }}"
description: |
Optional scopes of the token.
UPDATE examples
- tokens_update
Updates the comment or scopes of a token.
UPDATE databricks_workspace.settings.tokens
SET
token = '{{ token }}',
update_mask = '{{ update_mask }}'
WHERE
token_id = '{{ token_id }}' --required
AND deployment_name = '{{ deployment_name }}' --required
AND token = '{{ token }}' --required
AND update_mask = '{{ update_mask }}' --required;
Lifecycle Methods
- delete
Revokes an access token.
EXEC databricks_workspace.settings.tokens.delete
@deployment_name='{{ deployment_name }}' --required
@@json=
'{
"token_id": "{{ token_id }}"
}'
;