Embed a Dashboard Using a Generated Snippet and Trusted Access Tokens
insightsoftware recommends using Trusted Access for all embed-related workflows.
To embed a dashboard into your application using Trusted Access Tokens:
Verify that the embedded dashboard prerequisites have been met. See Embedded Component Prerequisites.
Use the Composer API to register your host application as a Trusted Access client of your Composer instance and obtain a client ID and client secret. See Trusted Access - Register a Client.
Add a
window.composerGetToken
function to your host application to obtain an access token and expiration for a user session when a user uses the embedded dashboard.The
composerGetToken
function must communicate with a server you have created (see Step 4) that takes information about the active user session (the user name) and contacts Composer to generate an access token for the user session. This is anasync
function that returns a promise. For example:window.composerGetToken = async function composerGetToken() { return { access_token: "<access_token>", expires_in: <seconds> }; };
Where
<access-token>
is the Trusted Access token you obtain from your server and<seconds>
is the number of seconds until the token expires.Implement your own server-side code that accepts requests generated by the
window.composerGetToken
function and, in turn, makes requests to Composer to generate a token for the specific user session of a user using the embedded dashboard. Your server-side code should respond to these requests with a token and expiration information.To generate an access token for the user, call the Trusted Access push/tokens API to generate tokens for new Composer users, or the pull/tokens API to retrieve tokens for existing users. See Trusted Access API Endpoints and Trusted Access
Generate and copy the embeddable snippet for your dashboard. See Generate an Embeddable Dashboard HTML Snippet.
Insert the generated snippet into your host application using the appropriate
script
tag, configured to show the embedded dashboard in the appropriate HTML element.
Comments
0 comments
Please sign in to leave a comment.