Skip to main content

Embedding With JavaScript

This applies to: Managed Dashboards, Managed Reports

Using the embed library with JavaScript provides similar options compared to others available in Symphony, but you can gain more control of the embedded application. For example:

  • Set view parameters from JavaScript.

  • Load different Symphony pages or refresh them.

  • Monitor the embedded SymphonyI client application's events.

  • Run JavaScript within the embedded Symphony client application and get messages sent back (if enabled).

Some of these functions may require setting up cross-origin resource sharing (CORS) for your site in Symphony to authorize it. See Configure Cross-Origin Resource Sharing (CORS).

After you define your logon option(s), see the following topics for more information about embedding with JavaScript.

Get a Logon Token

When not using one of the other automatic logon options described in the article Single sign-on (SSO), it is common to use logon tokens or session tokens to log users on automatically based on their existing session in the application that is embedding Symphony.

Important: When getting a logon or session token, it is best practice to do so at the server. Specifying hard-coded credentials within the client-side script itself makes these credentials available to users viewing the page script. Examples for server-side code are given below.

The following example gets a logon token for use with a Symphony embedded application at the client using specified credentials for demonstration purposes only. For an example of how to use server-side code to get a logon token securely and use it with the embed library, see the Symphony viewer integration sample web application and the examples provided for POST /LogOn/Token in the REST API. For more information and links regarding logon and session tokens, see Single sign-on (SSO).

... <head> <script src="/Scripts/Embed/dundas.embed.min.js" type="text/javascript" ></script> </head> ... <body> <script type="text/javascript"> document.addEventListener("DOMContentLoaded", function (event) { // ***************************************************************************** // It is a best practice to get the logon token at the server. // Credentials should not be specified directly in script unless they should be // freely available to users. // ***************************************************************************** dundas.embed.logon.getLogonToken( 'https://placeholder.dundas-bi-url.com/', { "accountName": "viewer", "password": "1234", "isWindowsLogOn": true }, function(getLogOnTokenResultData) { alert(getLogOnTokenResultData.logOnToken); } ); }); </script> </body>

Note: When getting a logon token to a site using HTTPS, the xmlHttpRequest adds the withCredentials flag with a true value to ensure the origin header is sent. The property dundas.embed.logon.disableWithCredentialsFlag, when set to true will not send the withCredentials property when getting the logon token.

Was this article helpful?

We're sorry to hear that.

Powered by Zendesk