@expertbridge-ui/embedded-sdk
v2.0.0
Published
SDK for embedding resources from Expertbridge into your own application
Downloads
1
Maintainers
Readme
Expertbridge Embedded SDK
The Embedded SDK allows you to embed dashboards from Expertbridge into your own app, using your app's authentication.
Embedding is done by inserting an iframe, containing a Expertbridge page, into the host application.
Embedding a Dashboard
Using npm:
npm install --save @expertbridge-ui/embedded-sdk
import { embedDashboard } from "@expertbridge-ui/embedded-sdk";
embedDashboard({
id: "abc123", // given by the Expertbridge embedding UI
expertbridgeDomain: "https://expertbridge.example.com",
mountPoint: document.getElementById("my-expertbridge-container"), // any html element that can contain an iframe
fetchGuestToken: () => fetchGuestTokenFromBackend(),
dashboardUiConfig: { hideTitle: true }, // dashboard UI config: hideTitle, hideTab, hideChartControls (optional)
});
You can also load the Embedded SDK from a CDN. The SDK will be available as expertbridgeEmbeddedSdk
globally:
<script src="https://unpkg.com/@expertbridge-ui/embedded-sdk"></script>
<script>
expertbridgeEmbeddedSdk.embedDashboard({
// ... here you supply the same parameters as in the example above
});
</script>
Authentication/Authorization with Guest Tokens
Embedded resources use a special auth token called a Guest Token to grant Expertbridge access to your users,
without requiring your users to log in to Expertbridge directly. Your backend must create a Guest Token
by requesting Expertbridge's POST /security/guest_token
endpoint, and pass that guest token to your frontend.
The Embedding SDK takes the guest token and use it to embed a dashboard.
Creating a Guest Token
From the backend, http POST
to /security/guest_token
with some parameters to define what the guest token will grant access to.
Guest tokens can have Row Level Security rules which filter data for the user carrying the token.
The agent making the POST
request must be authenticated with the can_grant_guest_token
permission.
Example POST /security/guest_token
payload:
{
"user": {
"username": "stan_lee",
"first_name": "Stan",
"last_name": "Lee"
},
"resources": [{
"type": "dashboard",
"id": "abc123"
}],
"rls": [
{ "clause": "publisher = 'Nintendo'" }
]
}