Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
kian0417
Regular Visitor

Refresh and generate embed token using JavaScript SDK

Hi,

I had embedded the report on my web page.
But my embed token will expire after 1 hour, so I need to keep to generate the token in Powershell.

Then, I am trying to use javascript SDK to generate embed token and refresh when the token is expired. But when I run the function, it will get an error and failed to implement the function.

The refresh token function is something like as below link:

Refresh token using JavaScript SDK example 

3 REPLIES 3
kian0417
Regular Visitor

The error is something like below:

 

error.png

Anonymous
Not applicable

Hi @kian0417 

The 'generateEmbedToken' as shown in that Wiki example, is a placeholder for you to put your own function in.
You will need to create a function that can call into the Power BI REST API -> https://docs.microsoft.com/en-us/rest/api/power-bi/embedtoken/reports_generatetokeningroup

It sounds as though you are already using this, as you have the initial embedding process working.
There is no built-in function in the Javacript API for automatically doing this action.

Hope this helps.

Noted with thanks.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.