【问题标题】:How to embed superset dashboard into your app如何将 superset 仪表板嵌入到您的应用程序中
【发布时间】:2023-01-18 18:00:52
【问题描述】:

在这里,我尝试使用 @superset-ui/embedded-sdk, 将超集 dashborad 嵌入到我的本地 .net 核心 Web 应用程序中 我正在使用 docker 方法在我的本地计算机中部署超集服务器,并且能够在我的超集服务器中创建和发布仪表板 但是当我将该仪表板嵌入到我的应用程序中时,它以空白页面结束并且出现控制台错误,有帮助吗?

这是我的代码

<div><iframe id="super"></iframe></div>
<script src="https://unpkg.com/@@superset-ui/embedded-sdk"></script>
<script>
    supersetEmbeddedSdk.embedDashboard({
        id: "***************", 
        supersetDomain: "http://localhost:8088/",
        mountPoint: document.getElementById("super"), 
        fetchGuestToken: () => getToken(),
        dashboardUiConfig: { hideTitle: true }, 
    });
async function getToken() {
        const { data: token } = await axios.post(
            'http://localhost:8088/api/v1/security/login',
            {
                username: '***',
                password: '***',
                provider: 'db',
                refresh: false,
            }
        );
        console.log('access token here');
        console.log(token.access_token);            
        try {
            var data = await axios.post(
                'http://localhost:8088/api/v1/security/guest_token/',
                {
                    user: {
                        username: '***',
                        first_name: '***',
                        last_name: '***',
                    },
                    rls: [],
                    resources: [
                        {
                            type: 'dashboard',
                            id: '************',
                        },
                    ],
                },
                {
                    headers: {                           
                        Authorization: `Bearer ${token.access_token}`,
                    },
                },
            );
            console.log('guest token here');
            console.log(data);
            return data.data.token;
        } catch (e) {
            console.error(e.message);
            console.error(e);
            return e;
        }
    }
</script>

控制台错误:

【问题讨论】:

  • 请注意,我仍在尝试让超集显示在我的身上,但为了克服 403 错误,我必须让我的 fetchGuestToken 返回一个解析为令牌值本身的承诺,而不是 {token: "tokeValue"} 的结构
  • 是的,我将承诺更新为令牌值本身,但仍然得到 403 error 。关于这个的任何线索?

标签: apache-superset


【解决方案1】:

你好。我试图将它嵌入到 iframe 中,但没有显示嵌入式仪表板菜单。

【讨论】:

    猜你喜欢
    • 2022-09-29
    • 1970-01-01
    • 1970-01-01
    • 2019-08-27
    • 1970-01-01
    • 1970-01-01
    • 2021-09-19
    • 2022-12-14
    • 2017-05-28
    相关资源
    最近更新 更多