# 范围限定令牌：最佳实践

impact.com 允许您创建 *范围限定令牌*：具有细粒度权限的 API 凭证，可授予对特定 API 端点的访问权限。了解更多关于 [确保您的令牌安全](/other/zh/readme/api-access-tokens-and-changelog/keep-your-access-tokens-secure.md).

<div data-with-frame="true"><figure><img src="/files/009789517c37ed372aaa6ce99c0f6b911a6b10c1" alt=""><figcaption></figcaption></figure></div>

#### 范围限定令牌的优势

<details>

<summary>更强的安全性</summary>

范围限定令牌只允许访问所需内容，从而在凭证泄露时降低风险。

</details>

<details>

<summary>更好的访问控制</summary>

为每个令牌可通过特定 API 执行的操作设置具体权限。

</details>

<details>

<summary>简化管理</summary>

简化令牌管理，尤其是在与多个团队或外部合作伙伴协作时。

</details>

<details>

<summary>洞察性监控</summary>

深入了解令牌使用情况，更好地理解 API 流量并有效管理速率限制。

</details>

<details>

<summary>改进的令牌管理</summary>

轻松创建、管理和撤销令牌，而不会影响其他集成。

</details>

#### 创建范围限定令牌的最佳实践

在创建范围限定令牌时，请遵循以下最佳实践，以确保安全性、清晰度和有效管理：

<details>

<summary>只选择您需要的 API 和方法</summary>

通过仅选择您的集成实际需要的特定 API 和 HTTP 方法（如 GET、POST、PUT、DELETE）来定义作用域。如果您的集成只需要检索数据，则仅使用 GET 方法授予对该 API 的访问权限。

</details>

<details>

<summary>应用最小权限原则</summary>

始终从所需的最低访问级别开始，仅在绝对必要时再添加更多权限。除非您的集成明确需要，否则避免启用 POST、PUT 或 DELETE 方法。

</details>

<details>

<summary>使用描述性名称和说明</summary>

为每个令牌提供清晰、有意义的名称，并包含详细说明。这有助于您的团队更有效地管理、理解和审计令牌使用情况。

</details>

<details>

<summary>指定负责的技术联系人</summary>

确保每个令牌都有指定的技术联系人。此人将负责接收与 API 访问和集成性能相关的重要更新、提醒或通知。

</details>

<details>

<summary>选择正确的 API 版本</summary>

确保令牌与您的集成所使用的 API 版本保持一致。这有助于保持兼容性并防止意外错误。

</details>

#### 监控和管理范围限定令牌

<details>

<summary>定期检查令牌使用情况</summary>

养成定期检查令牌使用方式的习惯。您可以通过设置仪表板来跟踪令牌活动，或向 impact.com 索取使用详情。同时，注意集成中的频繁错误。

</details>

<details>

<summary>避免授予过多访问权限</summary>

如果令牌拥有超出所需的权限，一旦泄露就会很危险。为防止这种情况，请比较令牌被允许执行的操作与其实际执行的操作。如果它拥有不需要的访问权限，请将其移除。

</details>

<details>

<summary>经常轮换令牌</summary>

定期更改令牌凭证，以帮助保障系统安全。尽量每隔几个月更新一次令牌——每季度一次是个不错的做法。创建新令牌后，请确保更新您的集成以使用新的令牌。

</details>

<details>

<summary>使用清晰的名称和描述</summary>

为每个令牌提供一个名称和描述，说明该令牌的用途及其所有者。包含使用该令牌的应用或系统、用途，以及它是用于测试还是线上环境等信息。此外，为团队中每个令牌指定一名主要联系人，以便在出现问题时联系。

</details>

<details>

<summary>移除未使用的令牌</summary>

旧令牌或未使用的令牌可能带来安全风险。安排定期清理——每月或每季度一次——检查所有令牌。删除或停用任何不再需要的令牌。

</details>

#### 常见问题

<details>

<summary>现有集成会受到影响吗？</summary>

不会。使用旧版令牌的现有集成将继续运行。不过，我们建议迁移到范围限定的 API 访问令牌，以获得更好的安全性和管理能力。

</details>

<details>

<summary>什么是旧版令牌？</summary>

*旧版令牌* 是一种较早的访问令牌类型，早于 *范围限定令牌*。范围限定令牌在 2025 年 5 月之后可在 impact.com 上使用。

</details>

<details>

<summary>保持令牌安全的最佳实践是什么？</summary>

了解更多关于 [确保您的访问令牌安全](/other/zh/readme/api-access-tokens-and-changelog/keep-your-access-tokens-secure.md).

</details>

<details>

<summary>我可以创建多少个范围限定令牌？</summary>

每个账户最多可拥有 20 个处于激活状态的范围限定令牌。可根据需要停用或删除令牌。

</details>

<details>

<summary>令牌被停用时会发生什么？</summary>

被停用的令牌将被拒绝访问，并返回 403“访问被拒绝”响应。这样可以在不删除令牌的情况下进行临时停用。

</details>

<details>

<summary>可以恢复已删除的令牌吗？</summary>

不可以，删除功能会永久删除访问令牌及其分配的任何权限。如果您误删了令牌，您可以创建一个新令牌并选择作用域。现有集成需要更新为使用新的访问令牌凭证。

</details>

<details>

<summary>范围限定令牌可以进行速率限制吗？</summary>

可以，范围限定访问令牌属于已实施的账户级速率限制的一部分。

</details>

<details>

<summary>范围限定令牌支持哪种身份验证方式？</summary>

我们的范围限定访问令牌仅支持基本身份验证。

</details>

<details>

<summary>如果使用无效令牌访问 API 会怎样？</summary>

如果您在没有有效范围限定访问令牌的情况下向 API 发出请求，您将看到 403“访问被拒绝”响应。

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.impact.com/other/zh/readme/api-access-tokens-and-changelog/scoped-tokens-best-practices.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
