令牌 APIToken API

通过令牌 API,可创建、列出和撤销能用于对 Azure Databricks REST API 进行身份验证和访问的令牌。The Token API allows you to create, list, and revoke tokens that can be used to authenticate and access Azure Databricks REST APIs.

重要

要访问 Databricks REST API,必须进行身份验证To access Databricks REST APIs, you must authenticate.

创建 Create

端点Endpoint HTTP 方法HTTP Method
2.0/token/create POST

创建并返回令牌。Create and return a token. 如果当前未过期的令牌数量超过令牌配额,则此调用将返回错误 QUOTA_EXCEEDEDThis call returns the error QUOTA_EXCEEDED if the current number of non-expired tokens exceeds the token quota. 用户的令牌配额为 600。The token quota for a user is 600.

请求示例:Request example:

{
  "lifetime_seconds": 100,
  "comment": "this is an example token"
}

响应示例:Response example:

{
  "token_value":"dapideadbeefdeadbeefdeadbeefdeadbeef",
  "token_info": {
    "token_id":"5715498424f15ee0213be729257b53fc35a47d5953e3bdfd8ed22a0b93b339f4",
    "creation_time":1513120516294,
    "expiry_time":1513120616294,
    "comment":"this is an example token"
  }
}

请求结构 Request structure

字段名称Field Name 类型Type 描述Description
lifetime_secondslifetime_seconds LONG 令牌的生存期,以秒为单位。The lifetime of the token, in seconds. 如果未指定生存期,则令牌始终有效。If no lifetime is specified, the token remains valid indefinitely.
commentcomment STRING 要附加到令牌的可选说明。Optional description to attach to the token.

响应结构Response structure

字段名称Field Name 类型Type 描述Description
token_valuetoken_value STRING 新创建的令牌的值。The value of the newly-created token.
token_infotoken_info 公共令牌信息Public token info 新创建的令牌的公共元数据。The public metadata of the newly-created token.

列表 List

端点Endpoint HTTP 方法HTTP Method
2.0/token/list GET

列出用户-工作区对的所有有效令牌。List all the valid tokens for a user-workspace pair.

响应示例:Response example:

{
  "token_infos": [
    {
      "token_id":"5715498424f15ee0213be729257b53fc35a47d5953e3bdfd8ed22a0b93b339f4",
      "creation_time":1513120516294,
      "expiry_time":1513120616294,
      "comment":"this is an example token"
    },
    {
      "token_id":"902eb9ac42c9bef80d0097a2d1746533103c88593add482a331500187946ceb5",
      "creation_time":1512684023036,
      "expiry_time":-1,
      "comment":"this is another example token"
    }
  ]
}

响应结构 Response structure

字段名称Field Name 类型Type 描述Description
token_infostoken_infos 公共令牌信息的数组An array of Public token info 用户-工作区对的令牌信息列表。A list of token information for a user-workspace pair.

撤销 Revoke

端点Endpoint HTTP 方法HTTP Method
2.0/token/delete POST

撤销访问令牌。Revoke an access token. 如果具有指定 ID 的令牌无效,则此调用将返回错误 RESOURCE_DOES_NOT_EXISTThis call returns the error RESOURCE_DOES_NOT_EXIST if a token with the specified ID is not valid.

请求示例:Request example:

{"token_id":"5715498424f15ee0213be729257b53fc35a47d5953e3bdfd8ed22a0b93b339f4"}

请求结构Request structure

字段名称Field Name 类型Type 描述Description
token_idtoken_id STRING 要撤销的令牌的 ID。The ID of the token to be revoked.

数据结构 Data structures

本节内容:In this section:

公共令牌信息 Public token info

描述访问令牌的公共元数据的数据结构。A data structure that describes the public metadata of an access token.

字段名称Field Name 类型Type 描述Description
token_idtoken_id STRING 令牌 ID。The ID of the token.
creation_timecreation_time LONG 创建令牌时的服务器时间(从 epoch 开始的毫秒数)。Server time (in epoch milliseconds) when the token was created.
expiry_timeexpiry_time LONG 令牌过期时的服务器时间(从 epoch 开始的毫秒数);如果不适用,则为 -1。Server time (in epoch milliseconds) when the token will expire, or -1 if not applicable.
commentcomment STRING 创建令牌时的注释(如果适用)。Comment the token was created with, if applicable.