GitHub user dosubot[bot] added a comment to the discussion: How to embed a
dashboard if OAUTH is enabled?
<!-- Answer -->
To embed a dashboard with OAUTH enabled, you can use a Guest Token for
authentication. Here's how you can do it using the Superset Embedded SDK:
1. Install the SDK using npm:
```sh
npm install --save @superset-ui/embedded-sdk
```
2. Use the `embedDashboard` function and provide a function to fetch the Guest
Token from your backend:
```js
import { embedDashboard } from "@superset-ui/embedded-sdk";
embedDashboard({
id: "abc123", // given by the Superset embedding UI
supersetDomain: "https://superset.example.com",
mountPoint: document.getElementById("my-superset-container"), // any html
element that can contain an iframe
fetchGuestToken: () => fetchGuestTokenFromBackend(), // Function to fetch
the guest token
dashboardUiConfig: {
hideTitle: true,
filters: {
expanded: true,
},
urlParams: {
foo: 'value1',
bar: 'value2',
}
},
iframeSandboxExtras: ['allow-top-navigation',
'allow-popups-to-escape-sandbox'],
referrerPolicy: "same-origin"
});
```
3. Ensure your backend creates a Guest Token by requesting Superset's `POST
/security/guest_token` endpoint and passes it to the frontend
<sup>[[1]](https://github.com/apache/superset/blob/master/superset-embedded-sdk/README.md)</sup>.
<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
---
<sup>Help Dosu learn! Give it feedback: [Great
Response](https://app.dosu.dev/response-feedback/39702a82-de2d-455a-a139-dcfe6d587068?feedback_type=great_response)
| [Irrelevant
Answer](https://app.dosu.dev/response-feedback/39702a82-de2d-455a-a139-dcfe6d587068?feedback_type=irrelevant_answer)
| [Incorrect
Sources](https://app.dosu.dev/response-feedback/39702a82-de2d-455a-a139-dcfe6d587068?feedback_type=incorrect_sources)
| [Too
Verbose](https://app.dosu.dev/response-feedback/39702a82-de2d-455a-a139-dcfe6d587068?feedback_type=too_verbose)
|
[Hallucination](https://app.dosu.dev/response-feedback/39702a82-de2d-455a-a139-dcfe6d587068?feedback_type=hallucination)
| [Bug
Report](https://app.dosu.dev/response-feedback/39702a82-de2d-455a-a139-dcfe6d587068?feedback_type=bug_report)
|
[Other](https://app.dosu.dev/response-feedback/39702a82-de2d-455a-a139-dcfe6d587068?feedback_type=other)</sup>
GitHub link:
https://github.com/apache/superset/discussions/33066#discussioncomment-12782380
----
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]