Kranthi32 commented on issue #32903:
URL: https://github.com/apache/superset/issues/32903#issuecomment-2762973256
I created user settings -) list of users -) role public
Another user gama role
2 runnkng 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 in react applivation chats loading.
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();
}, []);
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]