> 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/brand/zh/what-would-you-like-to-learn-about/advocate-program/manage-advocate-participant-experiences/microsite-experiences/set-up-sso-for-an-impactcom-microsite-via-jwt.md).

# 通过 JWT 为 impact.com 微站设置 SSO

你的 Advocate 计划的微站点通常要求你的客户 Advocate 先使用用户名和密码注册，然后才能访问他们的分享链接和奖励详情。不过，作为一种高级替代方案，你也可以通过生成一个 [JSON Web 令牌（JWT）](https://en.wikipedia.org/wiki/JSON_Web_Token) 在服务器端并通过 URL 参数将其传递给微站点。

使用这种方法，参与者将不会拥有微站点的登录凭据。相反，他们通过登录你现有的客户门户来获得访问权限，然后客户门户会使用 JWT 标识他们并显示其个性化内容，将他们重定向到微站点。

#### 开始之前

{% hint style="warning" %}
**重要：** 这是一个高级实现，它绕过了微站点的标准托管身份服务，并且需要开发团队的支持来进行设置。
{% endhint %}

仅当以下所有情况都适用时，你才应使用此方法：

* 你希望通过自动将参与者登录到你计划的微站点来模拟单点登录（SSO）体验。
* 你可以在服务器端生成 JWT。
* 你不能或不想安装 [通用跟踪标签（UTT）](/brand/zh/what-would-you-like-to-learn-about/platform-features/tracking/javascript-tag-tracking/tracking-with-universal-tracking-tag-utt.md) 到你的网站上。

{% stepper %}
{% step %}

#### 第 1 步：创建一个不使用托管身份的微站点

在创建微站点时，你需要关闭托管身份服务，然后将所有页面设置为对“未验证”用户可访问。 *仪表板* 页面将使用 JWT 对用户进行身份验证并加载微站点。

<details>

<summary>创建微站点</summary>

首先，调整设置以关闭 *参与者登录* 选项。

1. 在左侧导航菜单中，选择 ![](/files/4ce7c16cfcd5293cf28d16fe68b852009fc2468d) **\[Engage]** **→ 内容**.
2. 在 *微站* 卡片中，选择 **编辑设置**.
3. 然后你将被重定向到你的新 *微站点设置* 页面中。
4. 在 *登录* 部分， ![](/files/c2dcdffe00f000bd34f794287e3006cfa55e8ce8) **\[切换关闭]** **参与者登录**.
5. 选择 **保存设置**.

</details>

<details>

<summary>配置仪表板页面</summary>

接下来，将你的微站点的 *仪表板* 页面配置为对未验证用户可见。然后，将页面上的组件与你的推荐计划连接起来，以便显示正确的信息。

1. 调整你网站的 *仪表板* 页面设置。
   * 在左侧导航菜单中，选择 ![](/files/4ce7c16cfcd5293cf28d16fe68b852009fc2468d) **\[Engage]** **→ 内容** → **设置内容** 或 **编辑内容**.
   * 在 *微站* 选项卡来添加新的分享按钮，选择 **仪表板** 中输入一个 *已登录布局* 部分。
   * 选择 ![](/files/77cad707ec8c8e3ea9d0056e8451a6deaf59419d) **\[菜单] → 设置**.
   * 在 *允许的用户* 下拉列表中，选择 **未验证**.
2. 将你的计划 ID 添加到 *仪表板*.
   * 用户统计 — 你必须将该 ID 添加到你选择显示的每一项单独用户统计数据中。
   * 分享链接
   * 推荐代码
   * 社交媒体按钮 — 你必须将该 ID 添加到你选择包含的每一个单独社交媒体分享按钮中。
3. 在右上角，选择 **保存**.

   <div data-with-frame="true"><figure><img src="/files/366154043967c6dc4cb7b201cb635e01da353fa9" alt="" width="563"><figcaption></figcaption></figure></div>

有关使用编辑器查找并调整页面和组件设置的帮助，请参阅 [微型站点编辑器说明](/brand/zh/what-would-you-like-to-learn-about/advocate-program/manage-advocate-participant-experiences/microsite-experiences/microsite-editor-explained.md) 和 [自定义微站点布局和页面](/brand/zh/what-would-you-like-to-learn-about/advocate-program/manage-advocate-participant-experiences/microsite-experiences/customize-microsite-layouts-and-pages.md).

</details>

<details>

<summary>移除不必要的页面</summary>

移除你的微站点不会使用的布局和页面。

1. 将光标悬停在页面或布局上。
2. 选择 ![](/files/48274f9251fd79e93a99aad7b4393690b07a61c9) **\[更多]** **→ 删除**.
3. 删除 *已登录布局*.
4. 删除以下页面：
   * 编辑个人资料
   * 邮箱验证
   * 忘记密码
   * 登录
   * 登出
   * 注册
   * 重置密码
   * 验证邮箱

</details>
{% endstep %}

{% step %}

#### 第 2 步：生成 JWT

JWT 结构遵循用户身份验证的标准 Advocate 要求。如果你以前集成过 Advocate，你很可能已经在为 UTT 生成类似的令牌。

你必须在服务器或任何受信任的后端系统上安全地生成 JWT——绝不能在浏览器中生成。

了解如何 [生成 JWT 以及有效负载要求](https://integrations.impact.com/integration-guides/for-brands/advocate/advocate-tracking-integrations/json-web-tokens-jwts).
{% endstep %}

{% step %}

#### 第 3 步：将 JWT 附加到微站点 URL

一旦用户登录到你的平台，就将他们重定向到包含 URL 查询字符串中 JWT 的微站点。

{% hint style="info" %}
**示例：** `https://your-microsite.squatch.app/?jwt=<YOUR_GENERATED_JWT>`
{% endhint %}

你可以在新的浏览器标签页中打开微站点，或者使用 iframe 将微站点嵌入到你的应用中。如果你决定嵌入微站点，请确保你妥善处理 [跨域资源共享（CORS）](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing) 以及浏览器限制。
{% endstep %}
{% endstepper %}

#### 注意

* 如果你使用这种身份验证方法，用户将不会拥有微站点的登录凭据。
* 基于 JWT 的访问必须受到严格控制。不要在客户端 JavaScript 中暴露或操纵它。
* 这是一种非标准方法——在正式推出你的计划之前，请在预发布环境中对其进行彻底测试。
* 如果你需要 [支持](mailto:saasquatch-support@impact.com)，请在你的支持请求中包含你的微站点 URL、实施细节以及一个示例 JWT 有效负载。


---

# 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 dynamically by asking a question.

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

```
GET https://help.impact.com/brand/zh/what-would-you-like-to-learn-about/advocate-program/manage-advocate-participant-experiences/microsite-experiences/set-up-sso-for-an-impactcom-microsite-via-jwt.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
