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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
benjaminslarsen
Regular Visitor

Extend token lifetime in powerbi embedded in powerappsportal

We are building a powerapps portal where we embed powerbi content using powerapps’ liquid powerbi integration. [1]

This is the following tag that we are using for the integration.

 

{% powerbi authentication_type:"powerbiembedded" path:pbi_path roles:webroles %}

 

But the token generated by this tag is only valid for 30-40 minutes. After this, all the visuals break down with a 403 code.

 

error_pbi.png

We want to extend the lifetime of the page to a full day.

 

Firstly, we tried to set another AccessTokenLifetime using the guide described here https://docs.microsoft.com/en-us/azure/active-directory/develop/configure-token-lifetimes#create-a-p..., but the New-AzureADPolicy command is depreciated.

Then we tried to set policy in “conditional access” to set the sign-in frequency to 12 hours, but no luck here, the tokens still expire after 30-40 minutes.

 

From here, I only see to solutions, eighter we set up our own server to create new access token there can be applied in the powerbi api described here: https://docs.microsoft.com/en-us/javascript/api/overview/powerbi/refresh-token We rather not having any extra server to handle this. pure access token cant be generated by the available liqued tags in power portals.

Or it can be solved using the hacky method of requesting the same page, parse the token out of the html, and apply that, which is a method we don’t like eighter, this feels to unstable.

 

let page = await (await fetch(".")).text();
let parser = new DOMParser();
let xmlDoc = parser.parseFromString(page,"text/html");
let embedConfig = xmlDoc.querySelector('div[class*="portal-pbi-embedded"][embedConfig]').getAttribute("embedconfig");
let embedToken = JSON.parse(atob(embedConfig)).EmbedToken.token;
let report = powerbi.get($('.portal-pbi-embedded') [0]); // get report instance
await report.setAccessToken(embedToken);

 

Is there any way that it can be done better? Is there a place where the expiration time of the generated token can be set?

 

[1] https://docs.microsoft.com/en-us/powerapps/maker/portals/liquid/portals-entity-tags#powerbi

1 REPLY 1
v-cazheng-msft
Community Support
Community Support

Hi @benjaminslarsen 

You can refer the solution from v-lid-msft in this issue Expend the expiration time of Power BI report embedded token.

 

Best Regards

Caiyun Zheng

 

Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors