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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Chorda
Frequent Visitor

Refresh the token in PowerBI Embedded

I have embedded a Power BI report into my webapp using "Power BI Embedded" (following the model "embed for your customer").

 

All the token creation, sending them back and forth, works fine. But the token expires within 1-hr. I need to refresh the token it before it expires. Here is how to refresh the token: Refresh the access token in Power BI embedded analytics | Microsoft Docs

 

However the KEY to the solution is implementing the function getNewUserAccessToken() . 

 

There is already a similar post here https://community.powerbi.com/t5/Developer/How-to-implement-getNewUserAccessToken-function-for-Power...However, the "accepted solution" in this post works becasue the token acquisition in the Power Platform.

 

But I'm doing token acquisition via C# code as in standard "embed for your customer" .

 

What should the C# code look like for function getNewUserAccessToken()  in "embed for your customer"?

 

Help appreciated, 

 

( cc'ing you guys in case you know something @Anonymous @v-yiruan-msft )

1 REPLY 1
v-shex-msft
Community Support
Community Support

Hi @Chorda,

In fact, I think they should have similar logic.
You can create a similar function with 'if statement' and 'get token' API to get token and expiry date time to stored into global variables.
Then you can set a loop or timer to compare system time and expiration DateTime and invoke the generate new token function to update the stored tokens to update before the expiry date.

Embed Power BI report in a Power BI embedded analytics application for your customers - Power BI | M...
Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.