Facing issues while embedding quicksight console in webpage

Hi all,

I am trying to embed the Quicksight console experience into my webpage and for this, I used the GenerateEmbedUrlForRegisteredUser API operation. I was successfully able to generate the embed url using AWS CLI commands. But, when I tried to use this embed url into my html code, the embedding did not work. The url generated by the CLI command works if I paste it in the browser and I am able to see the Quicksight console but when I load the webpage, I get this error ‘us-east-1.quicksight.aws.amazon.com refused to connect’ .


In the Developer Tools’ Console, I see this error:-

Refused to frame ‘https://us-east-1.quicksight.aws.amazon.com/’ because an ancestor violates the following Content Security Policy directive: "frame-ancestors <my_website_link>

I know that the url can be only used once and has an expiration time of 5 mins. I haven’t used the url anywhere else before using it in my html code and used it within the time limit. Still, it doesn’t work.

This is the CLI command that I used to generate the embed url:-

aws quicksight generate-embed-url-for-registered-user --aws-account-id 01 --session-lifetime-in-minutes 60 --user-arn "arn:aws:quicksight:us-east-1:01:user/default/k***" --experience-configuration ‘{"QuickSightConsole": {"InitialPath": "/start","FeatureConfigurations":{ "StatePersistence": {"Enabled": true }}}}’ --allowed-domains “my_website_link” --region us-east-1

Below is the html code that I used which I found in the AWS documentation:-

<head>
    <title>Console Embedding Example</title>
    <script src="https://unpkg.com/amazon-quicksight-embedding-sdk@2.0.0/dist/quicksight-embedding-js-sdk.min.js"></script>
    <script type="text/javascript">
        const embedSession = async() => {    
            const {
                createEmbeddingContext,
            } = QuickSightEmbedding;

            const embeddingContext = await createEmbeddingContext({
                onChange: (changeEvent, metadata) => {
                    console.log('Context received a change', changeEvent, metadata);
                },
            });

            const frameOptions = {
                url: "<my_embed_url>", // replace this value with the url generated via embedding API
                container: '#experience-container',
                height: "700px",
                width: "1000px",
                onChange: (changeEvent, metadata) => {
                    switch (changeEvent.eventName) {
                        case 'FRAME_MOUNTED': {
                            console.log("Do something when the experience frame is mounted.");
                            break;
                        }
                        case 'FRAME_LOADED': {
                            console.log("Do something when the experience frame is loaded.");
                            break;
                        }
                    }
                },
            };

            const contentOptions = {
                onMessage: async (messageEvent, experienceMetadata) => {
                    switch (messageEvent.eventName) {
                        case 'ERROR_OCCURRED': {
                            console.log("Do something when the embedded experience fails loading.");
                            break;
                        }
                    }
                }
            };
            const embeddedConsoleExperience = await embeddingContext.embedConsole(frameOptions, contentOptions);
        };
    </script>
</head>

<body onload="embedSession()">
    <div id="experience-container"></div>
</body>

I don’t know what I’m doing wrong and cannot figure out the issue. Could someone please suggest what should be done for this?

1 Like

Hello @kajolshah310, welcome to the QuickSight community!

From what I can tell, it looks like you are retrieving the embeddable url correctly. Have you gone into the QuickSight console and whitelisted the url for the application that you are currently trying to embed the iframe in? If you click the person icon at the top right corner of QuickSight and select manage QuickSight. You can select the domains and embedding tab and add your urls for whitelisting there. I think that will resolve your problem. Let me know if this helps!

1 Like

Hi @DylanM , Thank you for your response. I have whitelisted the domain and when I tried passing the embed code for my dashboard, it worked fine and I was able to view my dashboard visuals. But it is not working for the embed url generated for console experience using the GenerateEmbedUrlForRegisteredUser operation.

1 Like

Hello @kajolshah310, is the div for “experience-container” showing up in the developer tools when you are checking the returned html? Do you have a screenshot of how that is displaying on the webpage? Also are you getting any error messages in the network tab?

1 Like

[quote=“kajolshah310, post:5, topic:27257”]
Hi @DylanM ,
Sorry for the delayed reply. I see errors in my Developer tools’ Console tab.
And yes, the div for experience-container is showing up in the developer tools in the returned html.


I am getting error messages in the Console tab and not in the Network tab.
Could you please suggest what can be wrong in this case?

Hello @kajolshah310, so I do think the likely issue is the allowed-domains section of the cli command. Make sure that unless you are using localhost that you are using a url containing https and not http. Also, are you following the suggested format, https://*.sapp.amazon.com, to handle any subdomains that appear? That may lead you in the right direction.

Hello @kajolshah310, since we have not heard back from you, I will mark my above response as the solution. Let me know if you have any follow-up questions!