GitHub user jpgomezv deleted a comment on the discussion: embed chart
To embed a single chart in Superset you need three things: the embed feature
enabled, CORS allowed for your origin, and a guest token.
1. In `superset_config.py`:
```python
EMBEDDED_SUPERSET = True
ENABLE_CORS = True
CORS_OPTIONS = {
"supports_credentials": True,
"allow_headers": ["*"],
"resources": ["*"],
"origins": ["https://your-app-domain.com"],
}
```
2. Restart Superset. On the chart, open the "Share" menu and enable **"Enable
embedding"** — this exposes the `/superset/embedded/<uuid>` URL for that chart.
3. From your app, mint a guest token:
```bash
curl -X POST https://your-superset/api/v1/security/guest_token/ \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{"resources": [{"type": "dashboard", "id": "<chart_uuid>"}], "rls": [],
"user": {"username": "guest"}}'
```
(For a single chart, the guest-token resource is keyed by the chart's UUID; the
exact `type` value has varied across Superset versions, so check your version's
docs — some expect `"chart"`.)
4. Render it in your page with the embedded SDK:
```html
<script src="https://unpkg.com/@superset-ui/embedded-sdk"></script>
<script>
embedChart({
id: '<chart_uuid>',
mountNode: document.getElementById('chart'),
fetchGuestToken: async () => '<guest_token>',
supersetDomain: 'https://your-superset',
chartUiConfig: { hideTitle: true },
});
</script>
```
If you only need the chart without the SDK, you can also iframe
`/superset/embedded/<chart_uuid>` once embedding + CORS are enabled and the
guest token is generated.
If this answers your question, feel free to mark it as the accepted answer!
GitHub link:
https://github.com/apache/superset/discussions/42887#discussioncomment-18058522
----
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]