> 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 体验](/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`. [使用认证令牌授权嵌入](/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 应用中嵌入体验](/api-docs/zh/cha-jian-yu-ji-cheng/convai-pixel-streaming-embed/react-typescript.md)，并加载页面。

{% hint style="success" %}
嵌入会显示 **点击以开始你的体验**。使用认证令牌时，它会显示 `无法启动此体验：Convai 认证令牌无效或已过期。` 如果 Convai 拒绝了该令牌。没有令牌时，它会显示 `请联系 convai 将 <origin> 加入白名单！` 如果该域名未被列入允许名单。
{% endhint %}

### 后续步骤

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

{% content-ref url="/pages/68922441d3a02dbe45f8a18c8887daf138b477cc" %}
[使用脚本标签嵌入体验](/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.
