``w.tokens``: Token =================== .. currentmodule:: databricks.sdk.service.settings .. py:class:: TokensAPI The Token API allows you to create, list, and revoke tokens that can be used to authenticate and access Databricks REST APIs. .. py:method:: create( [, autoscope_enabled: Optional[bool], comment: Optional[str], lifetime_seconds: Optional[int], scopes: Optional[List[str]]]) -> CreateTokenResponse Usage: .. code-block:: 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) 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**. :param autoscope_enabled: bool (optional) Whether to enable autoscoping for this token. When true, the token will automatically collect inferred API path scopes as it is used. :param comment: str (optional) Optional description to attach to the token. :param lifetime_seconds: int (optional) The lifetime of the token, in seconds. If the lifetime is not specified, this token remains valid for 2 years. :param scopes: List[str] (optional) Optional scopes of the token. :returns: :class:`CreateTokenResponse` .. py:method:: delete(token_id: str) Revokes an access token. If a token with the specified ID is not valid, this call returns an error **RESOURCE_DOES_NOT_EXIST**. :param token_id: str The ID of the token to be revoked. .. py:method:: list() -> Iterator[PublicTokenInfo] Usage: .. code-block:: from databricks.sdk import WorkspaceClient w = WorkspaceClient() all = w.tokens.list() Lists all the valid tokens for a user-workspace pair. :returns: Iterator over :class:`PublicTokenInfo` .. py:method:: update(token_id: str, token: PublicTokenInfo, update_mask: FieldMask) -> UpdateTokenResponse Updates the comment or scopes of a token. If a token with the specified ID is not valid, this call returns an error **NOT_FOUND**. :param token_id: str The SHA-256 hash of the token to be updated. :param token: :class:`PublicTokenInfo` :param update_mask: FieldMask A list of field name under token, For example, {"update_mask": "comment,scopes"} The field mask must be a single string, with multiple fields separated by commas (no spaces). The field path is relative to the resource object, using a dot (`.`) to navigate sub-fields (e.g., `author.given_name`). Specification of elements in sequence or map fields is not allowed, as only the entire collection field can be specified. Field names must exactly match the resource field names. A field mask of `*` indicates full replacement. It’s recommended to always explicitly list the fields being updated and avoid using `*` wildcards, as it can lead to unintended results if the API changes in the future. :returns: :class:`UpdateTokenResponse`