> ## Documentation Index
> Fetch the complete documentation index at: https://omer-914cc1c6.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 认证

> 你可以配置认证参数，让用户使用其实际的 API key。

<div id="enabling-authentication">
  ## 启用认证
</div>

你可以在 `docs.json` 中添加一种认证方式，将其全局应用于每个页面；也可以按页面单独设置。

当同时存在全局与页面级设置时，页面的认证方式会覆盖全局设置。

<div id="bearer-token">
  ### Bearer 令牌
</div>

<CodeGroup>
  ```json docs.json theme={null}
  "api": {
      "mdx": {
        "auth": {
          "method": "bearer"
        }
      }
  }
  ```

  ```mdx Page Metadata theme={null}
  ---
  title: "Your page title"
  authMethod: "bearer"
  ---
  ```
</CodeGroup>

<div id="basic-authentication">
  ### 基本认证
</div>

<CodeGroup>
  ```json docs.json theme={null}
  "api": {
      "mdx": {
        "auth": {
          "method": "basic"
        }
      }
  }
  ```

  ```mdx Page Metadata theme={null}
  ---
  title: "Your page title"
  authMethod: "basic"
  ---
  ```
</CodeGroup>

<div id="api-key">
  ### API key
</div>

<CodeGroup>
  ```json docs.json theme={null}
  "api": {
      "mdx": {
        "auth": {
          "method": "key",
          "name": "x-api-key"
        }
      }
  }
  ```

  ```mdx Page Metadata theme={null}
  ---
  title: "Your page title"
  authMethod: "key"
  ---
  ```
</CodeGroup>

<div id="none">
  ### 无
</div>

在 docs.json 中设置默认值后，可通过将认证方式设为 “none” 来为特定端点禁用认证。

<CodeGroup>
  ```mdx Page Metadata theme={null}
  ---
  title: "Your page title"
  authMethod: "none"
  ---
  ```
</CodeGroup>
