认证
通过传递访问者令牌或使用已验证访问,在需要认证的网站中使用 Docs Embed
方法一:直接传递令牌(推荐)
<script src="https://docs.company.com/~gitbook/embed/script.js"></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" },
},
});方法二:基于 Cookie 的检测
常见错误
调试
后续步骤
最后更新于
这有帮助吗?