Embedding failed because of invalid URL or authorization code. Both of these must be valid and the authorization code must not be expired for embedding to work

(1) I have C# code to get embedded dashboard url

var ret = await client.GetDashboardEmbedUrlAsync(new GetDashboardEmbedUrlRequest { AwsAccountId = _awsAccountID, DashboardId = _dashboardId, Namespace = default, IdentityType = EmbeddingIdentityType.QUICKSIGHT, SessionLifetimeInMinutes = 600, UndoRedoDisabled = true, ResetDisabled = true, UserArn = _userArn }).ConfigureAwait(false); return ret.EmbedUrl;

(2) After I get the embedded url, I uses

to embed the dashboard in html div

this.embeddedDashboard = await embeddingContext.embedDashboard(
			frameOptions,
			contentOptions
		);

(3) I used the embedded url several times with different data to display same quicksight dashboard to generate different reports.

(a) First call is successful
(b) Second call results in following error
Embedding failed because of invalid URL or authorization code. Both of these must be valid and the authorization code must not be expired for embedding to work.

How do I need to do resolve the issue?

Hello @hubaozhang , welcome to the QuickSight community!

I would check out these two topics where users ran into similar issues:

Thanks for the link. The link has answers why it is not working, but there is no answer how to solve the problem.

Hi @hubaozhang,
I would suggest exploring the QuickSight Developer Portal. It focuses on various embedding options and helps guide you through step by step processes. Please review and let us know if this helps with your case.