GitHub user Kranthi32 added a comment to the discussion: Refresh embedded
dahboard getting logiut supersetapp and embedded dasboard geeting forbidded
I created user settings -) list of users -) role public
Another user gama role
2 running react application dashboard showing
3 immediately superset app logging out
4 after refresh my react app showing guest token issue first time perfectly
loading
5 again i login into superset app. And react applivation chats loading.
Is it need loginto superset application every time?
Please support i am new to this
i added react code like this
my react application
"use client";
import React, { useEffect } from "react";
import axios from "axios";
import { embedDashboard } from "@superset-ui/embedded-sdk";
const supersetUrl = "http://localhost:8088/";
const supersetApiUrl = ${supersetUrl}/api/v1/security;
const dashboardId = "af70a229-7d8e-4917-8ce3-795ca257fa85";
const DashboardPage = () => {
useEffect(() => {
async function getToken() {
try {
const loginBody = {
password: "admin",
provider: "db",
refresh: true,
username: "sracharts",
};
const { data } = await axios.post(
${supersetApiUrl}/login,
loginBody,
{ headers: { "Content-Type": "application/json" }, withCredentials: true, }
);
const accessToken = data.access_token;
console.log("Access Token:", accessToken);
/*** Step 2: Fetch Guest Token ***/
const guestTokenBody = JSON.stringify({
resources: [{ type: "dashboard", id: dashboardId }],
rls: [{"clause": "customer_id=4"}],
user: { username: "sracharts", first_name: "Sra", last_name:
"Application" },
});
const guestTokenResponse = await axios.post(
`${supersetApiUrl}/guest_token/`,
guestTokenBody,
{ headers: { "Content-Type": "application/json", Authorization: `Bearer
${accessToken}` }, withCredentials: true, }
);
const guestToken = guestTokenResponse.data.token;
console.log("Guest Token:", guestToken);
/*** Step 3: Embed Dashboard ***/
const mountPoint = document.getElementById("superset-container");
if (!mountPoint) {
console.error("Error: mountPoint is null.");
return;
}
console.log('mount points')
embedDashboard({
id: dashboardId,
supersetDomain: supersetUrl,
mountPoint,
fetchGuestToken: () => guestToken,
dashboardUiConfig: {
filters: { expanded: true },
urlParams: { standalone: 3 },
},
});
/*** Step 4: Adjust Iframe Styles ***/
setTimeout(() => {
const iframe = document.querySelector("iframe");
if (iframe) {
iframe.style.width = "100%";
iframe.style.minHeight = "100vh";
}
}, 1000);
} catch (error) {
console.error("Error fetching token:", error);
}
}
getToken();
}, []);
GitHub link:
https://github.com/apache/superset/discussions/33892#discussioncomment-13566756
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]