> For the complete documentation index, see [llms.txt](https://help.impact.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.impact.com/other/zh/reference-documentation/api-access-tokens/migrate-to-scoped-tokens.md).

# 迁移到作用域令牌

旧版令牌是指在 2025 年 6 月 impact.com 推出作用域令牌之前创建的令牌。如果你目前使用旧版令牌向 impact.com API 进行身份验证，现在就该改用作用域令牌了。

旧版令牌可广泛访问所有面向客户的 API，带来显著的安全和运维风险。作用域令牌则是更安全、更易管理的替代方案。详细了解 [作用域令牌最佳实践](https://help.impact.com/other/zh/reference-documentation/api-access-tokens/scoped-tokens-best-practices.md).

#### 迁移步骤

<details>

<summary>1. 评估当前集成</summary>

首先，找出所有使用旧版令牌的现有集成（应用、脚本或服务）。在创建新令牌之前，你应了解切换到较新 API 版本可能带来的变化。

首先列出每个集成，并记录其功能、访问的具体端点、执行的操作类型（读取、写入或两者兼有），以及负责拥有或维护该集成的人员。

请特别留意不同 API 版本之间的任何不兼容变更。你应当：

* 检查请求负载，因为新版本可能会重命名字段、更改数据类型或要求提供新字段。数据结构不匹配是运行时错误的常见原因。
* 检查响应负载的结构，因为字段可能会被重命名、移除或采用不同的嵌套方式，因此你需要更新应用程序读取 API 响应的逻辑。

请参阅 [品牌](https://integrations.impact.com/brand-api-reference/readme/changelog), [合作伙伴](https://integrations.impact.com/partner-api-reference/readme/changelog)和 [代理机构](https://integrations.impact.com/agency-v3/readme/changelog) 的变更日志，了解版本更新。

</details>

<details>

<summary>2. 生成新的作用域令牌</summary>

完成评估后，你可以生成新的作用域令牌。请参阅我们的指南，了解如何 [创建 API 访问令牌](https://help.impact.com/other/zh/reference-documentation/api-access-tokens/create-an-api-access-token.md).

根据评估结果，列出集成使用的每个端点，并将每项操作（例如 `GET`, `POST`, `PUT`或 `DELETE` ）映射到新 API 版本中对应的最小权限范围。创建令牌时，只分配这些细粒度权限范围，使令牌仅满足该集成的具体需求。

生成令牌时，请选择目标 API 版本，因为该版本决定了令牌所授权的行为和数据结构。为尽量减少影响，你可以先沿用集成当前使用的版本，之后再单独规划升级。

最后，为令牌取一个能说明其用途和 API 版本的描述性名称（例如 Reporting\_v2\_Read-Only），并妥善保存新的凭据。

</details>

<details>

<summary>3. 测试集成</summary>

上线之前，应在预发布或开发环境中彻底测试更新后的集成。在该测试环境中，暂时修改集成代码，使其使用新的作用域令牌和新的 API 基础 URL。执行所有主要工作流，确认数据读取、创建、更新和删除均按预期运行。

作为安全测试的一部分，尝试访问新令牌权限范围未涵盖的端点。你应收到 `403 Forbidden` 错误，这表明令牌已正确限制访问。根据影响评估结果修正代码（例如更新请求/响应逻辑或字段名称）后，请重新测试并反复调整，直至所有功能正常运行。

</details>

<details>

<summary>4. 更新集成</summary>

测试成功后，就可以将变更部署到生产环境。请在生产代码库中落实所有已验证的代码更改和配置更新。

此处最重要的一步是用新的作用域令牌替换旧版令牌。新令牌启用后，请密切监控集成和应用程序日志，确保没有意外错误。

</details>

<details>

<summary>5. 沟通变更</summary>

确认新集成运行顺畅后，就该永久撤销或删除旧的、已停用的旧版令牌。这是至关重要的安全步骤，因为权限广泛的旧版令牌一旦遭到泄露，就会带来重大风险。

最后，请更新内部文档，并告知相关团队成员有关新令牌的信息。务必记录令牌的管理方式，以防止滥用，并确保今后维护顺利。

</details>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.impact.com/other/zh/reference-documentation/api-access-tokens/migrate-to-scoped-tokens.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
