w.tokens: Token

class databricks.sdk.service.settings.TokensAPI

The Token API allows you to create, list, and revoke tokens that can be used to authenticate and access Databricks REST APIs.

create([, comment: Optional[str], lifetime_seconds: Optional[int]]) CreateTokenResponse

Usage:

import time

from databricks.sdk import WorkspaceClient

w = WorkspaceClient()

token = w.tokens.create(comment=f'sdk-{time.time_ns()}', lifetime_seconds=300)

# cleanup
w.tokens.delete(token_id=token.token_info.token_id)

Create a user token.

Creates and returns a token for a user. If this call is made through token authentication, it creates a token with the same client ID as the authenticated token. If the user’s token quota is exceeded, this call returns an error QUOTA_EXCEEDED.

Parameters:
  • comment – str (optional) Optional description to attach to the token.

  • lifetime_seconds

    int (optional) The lifetime of the token, in seconds.

    If the lifetime is not specified, this token remains valid indefinitely.

Returns:

CreateTokenResponse

delete(token_id: str)

Revoke token.

Revokes an access token.

If a token with the specified ID is not valid, this call returns an error RESOURCE_DOES_NOT_EXIST.

Parameters:

token_id – str The ID of the token to be revoked.

list() Iterator[PublicTokenInfo]

Usage:

from databricks.sdk import WorkspaceClient

w = WorkspaceClient()

all = w.tokens.list()

List tokens.

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

Returns:

Iterator over PublicTokenInfo