How to obtain guest_token for embedded-sdk after disabling MFA and integrating Okta? #32893
Replies: 1 comment
-
|
Hey @rick-chou! I'm here to help you with any bugs or questions you have while waiting for a human maintainer. Let me know how I can assist you! To obtain a
import requests
def fetch_guest_token():
url = "https://superset.example.com/api/v1/security/guest_token"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer <your_access_token>"
}
payload = {
"user": {
"username": "guest_user"
},
"resources": [
{
"type": "dashboard",
"id": "your_dashboard_id"
}
],
"rls": []
}
response = requests.post(url, headers=headers, json=payload)
if response.status_code == 200:
return response.json().get("token")
else:
raise Exception("Failed to obtain guest token: " + response.text)
import { embedDashboard } from "@superset-ui/embedded-sdk";
async function fetchGuestTokenFromBackend() {
const response = await fetch('/your-backend-endpoint-to-fetch-guest-token');
const data = await response.json();
return data.token;
}
embedDashboard({
id: "abc123",
supersetDomain: "https://superset.example.com",
mountPoint: document.getElementById("my-superset-container"),
fetchGuestToken: fetchGuestTokenFromBackend,
dashboardUiConfig: {
hideTitle: true,
filters: {
expanded: true,
},
urlParams: {
foo: 'value1',
bar: 'value2',
}
},
iframeSandboxExtras: ['allow-top-navigation', 'allow-popups-to-escape-sandbox'],
referrerPolicy: "same-origin"
});This setup allows your frontend to obtain a guest token from your backend, which in turn requests it from Superset. Ensure that the request payload matches the schema expected by Superset's API, including user and resource details [1]. To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Beta Was this translation helpful? Give feedback.
All reactions