> For the complete documentation index, see [llms.txt](https://docs.convai.com/api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-pixel-streaming-embed/whitelisting-and-publishing-an-experience.md).

# 发布并授权体验

发布一个 Avatar Studio 体验，找到它的体验 ID，并通过服务器签发的身份验证令牌或已加入允许列表的域名授权你的网站进行嵌入。

准备好要嵌入的体验：发布体验，记下体验 ID，并确定 Convai 如何授权嵌入该体验的页面。每个体验只需执行一次，并在阅读任何嵌入指南之前完成。完成后，你将拥有一个体验 ID，以及一个返回身份验证令牌的服务器路由或一个已加入允许列表的域名。

### 前提条件

* 拥有 Avatar Studio 体验的 Convai 帐户。
* 如使用身份验证令牌：一个 Convai API 密钥和一台由你控制的服务器。

### 发布体验

从 Avatar Studio 的 **发布** 选项卡发布体验，具体说明请参阅 [发布 Avatar Studio 体验](https://docs.convai.com/api-docs/zh/wu-dai-ma-ti-yan/avatar-studio-experiences/customizing-your-avatar/publishing-an-experience.md)。记下体验 ID。嵌入代码会将其作为 `expId`.

更改体验后，请再次发布，以便嵌入代码加载最新版本。

### 选择嵌入代码的授权方式

每个嵌入会话都通过以下两种方式之一进行授权：

| 方法     | 工作原理                                        | 适用场景                                  |
| ------ | ------------------------------------------- | ------------------------------------- |
| 身份验证令牌 | 你的服务器使用 API 密钥生成一个短期令牌，页面再将其作为 `authToken`. | 你有一台服务器。适用于任何来源，包括 `localhost` 和预览部署。 |
| 域名允许列表 | Convai 会将页面的 `Referer` 主机名与体验创建者帐户中的域名进行比对。 | 网站是静态的，没有可生成令牌的服务器。                   |

身份验证令牌会以生成该令牌的帐户身份授权会话。该帐户可以打开公开和未列出的体验，以及由其创建或受邀参与的私有体验。

### 在服务器上生成身份验证令牌

身份验证令牌由你的服务器生成：服务器使用 API 密钥调用 Convai，页面再将返回结果作为 `authToken`. [使用身份验证令牌授权嵌入内容](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-pixel-streaming-embed/authorize-embeds-with-an-auth-token.md) 将逐步介绍服务器路由、缓存和嵌入接线配置。

### 改用域名允许列表

请让 Convai 将每个嵌入该体验的域名添加到账户的允许列表中。域名允许列表功能需要付费套餐，且可添加的域名数量取决于套餐。每个来源都需要单独添加，因此 `localhost` 和预览部署也需要添加。

Convai 会从页面的 `Referer` 标头读取域名。如果页面使用 `Referrer-Policy: no-referrer` 提供服务，则不会发送该标头，因此会话将被拒绝。

### 验证授权

使用其中一份指南嵌入体验，例如 [在 React TypeScript 应用中嵌入体验](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-pixel-streaming-embed/react-typescript.md)，然后加载页面。

{% hint style="success" %}
嵌入内容会显示 **点击以开始体验**。如果使用身份验证令牌，则会显示 `This experience couldn't start: the Convai auth token is invalid or has expired.` 如果 Convai 拒绝了该令牌。如果没有令牌，则会显示 `Please contact convai to get <origin> whitelisted!` 如果该域名未列入允许列表。
{% endhint %}

### 后续步骤

{% content-ref url="/pages/f044cf72f92d03a24caabe7e8ecdaa28ab4823ca" %}
[在 React TypeScript 应用中嵌入体验](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-pixel-streaming-embed/react-typescript.md)
{% endcontent-ref %}

{% content-ref url="/pages/68922441d3a02dbe45f8a18c8887daf138b477cc" %}
[使用脚本标签嵌入体验](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-pixel-streaming-embed/cdn-umd-script.md)
{% endcontent-ref %}


---

# 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://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-pixel-streaming-embed/whitelisting-and-publishing-an-experience.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.
