> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify-mintlify-add-hello-world-quickstart-48843.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 认证

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

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

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

当同时设置了全局方法和页面方法时，页面的认证方法会覆盖全局方法。

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

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

  ```mdx Page Metadata
  ---
  title: "Your page title"
  authMethod: "bearer"
  ---
  ```
</CodeGroup>

<div id="basic-authentication">
  ### Basic authentication
</div>

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

  ```mdx Page Metadata
  ---
  title: "Your page title"
  authMethod: "basic"
  ---
  ```
</CodeGroup>

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

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

  ```mdx Page Metadata
  ---
  title: "Your page title"
  authMethod: "key"
  ---
  ```
</CodeGroup>

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

在 docs.json 中设置默认值后，使用 "none" 认证方法可在某个特定端点上禁用认证。

<CodeGroup>
  ```mdx Page Metadata
  ---
  title: "Your page title"
  authMethod: "none"
  ---
  ```
</CodeGroup>
