身份验证
通过传递访客令牌或使用已验证访问方式,在需要身份验证的网站上使用文档嵌入
方法 1:直接传递令牌(推荐)
<script src="https://docs.company.com/~gitbook/embed/script.js?jwt_token=your-jwt-token"></script>
<script>
window.GitBook(
"init",
{ siteURL: "https://docs.company.com" },
{ visitor: { token: "your-jwt-token" } }
);
window.GitBook("show");
</script>import { createGitBook } from "@gitbook/embed";
const gitbook = createGitBook({
siteURL: "https://docs.company.com",
});
const iframe = document.createElement("iframe");
iframe.src = gitbook.getFrameURL({
visitor: {
token: "your-jwt-token",
unsignedClaims: { userId: "123", plan: "premium" },
},
});方法 2:基于 Cookie 的检测
常见问题
调试
下一步
最后更新于
这有帮助吗?