'How to extend powerBI token Id expiry time

How do I change the token Expiry time in power Bi?

Steps followed to generate token:

  1. Registered power Bi App
  2. After providing the details got the client id and the secret Id
  3. Using client id and secret Id, I generated the token Id on my asp.net page.
  4. Using this token Id, I am able to access power bi report and bind into iframe.

It's working but after 1-hour token Id expires and I need to generate the token Id again by providing the power username and password which the user doesn't want to key in.



Solution 1:[1]

Use setAccessToken to update the access token without reloading the embedded report when the token is about to expire. You can Refresh the token Manually or Automatically.

await report.setAccessToken(newAccessToken);

Manually Update token: Set the newAcessToken Manually

let newAccessToken = await getNewUserAccessToken(reportId, groupId);

Automatically Update token: Provide token generating function it will set an event hook in embed config parameters and call function which generates new token and reassign to generated expiring token

References:

https://docs.microsoft.com/javascript/api/overview/powerbi/refresh-token

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kotana Sai