Skip to main content

tokens

Creates, updates, deletes, gets or lists a tokens resource.

Overview

Nametokens
TypeResource
Iddatabricks_workspace.settings.tokens

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
token_idstringThe ID of this token.
autoscope_statestring
backfill_scopesarrayOutput only. Scopes inferred from offline backfill processing.
commentstringComment the token was created with, if applicable.
creation_timeintegerServer time (in epoch milliseconds) when the token was created.
expiry_timeintegerServer time (in epoch milliseconds) when the token will expire, or -1 if not applicable.
inferred_scopesarrayOutput only. Inferred API path scopes collected for this token when autoscope is enabled.
last_accessed_timeintegerServer time (in epoch milliseconds) when the token was accessed most recently.
scopesarrayScope of the token was created with, if applicable.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
listselectdeployment_nameLists all the valid tokens for a user-workspace pair.
createinsertdeployment_nameCreates and returns a token for a user. If this call is made through token authentication, it creates
tokens_updateupdatetoken_id, deployment_name, token, update_maskUpdates the comment or scopes of a token.
deleteexecdeployment_name, token_idRevokes 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.

NameDatatypeDescription
deployment_namestringThe Databricks Workspace Deployment Name (default: dbc-abcd0123-a1bc)
token_idstringThe SHA-256 hash of the token to be updated.

SELECT examples

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

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
;

UPDATE examples

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

Revokes an access token.

EXEC databricks_workspace.settings.tokens.delete
@deployment_name='{{ deployment_name }}' --required
@@json=
'{
"token_id": "{{ token_id }}"
}'
;