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.
commentstring
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.

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
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)

SELECT examples

Lists all the valid tokens for a user-workspace pair.

SELECT
token_id,
comment,
creation_time,
expiry_time
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 (
comment,
lifetime_seconds,
deployment_name
)
SELECT
'{{ comment }}',
{{ lifetime_seconds }},
'{{ deployment_name }}'
RETURNING
token_info,
token_value
;

Lifecycle Methods

Revokes an access token.

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