Forum Discussion
How to implement getNewUserAccessToken() function for PowerBI embedded
- Anonymous4 years ago
Hi Anonymous , I have created the PowerBI embedded by using creating a portal using the Power Platform. There I used the procedure mentioned here: Set up Power BI integration - Power Apps | Microsoft Docs
It was not possible to create the refresh token, because the token aquisition is done by the Power Platform.
However it was possible to extend the tokenlifetime by creating an Azure AD policy and assign it to the Power BI service account. I was struggling with it because I tried to extend the tokenlifetime of the PowerApp account that was registered in my tenant, that didn't solve the issue. The embedded PowerBI session still expired after hour.
Below the PowerShell script that I have used to extend the token lifetime to 23 hours and it works as expected.
# Login Connect-AzureAD Get-AzureADServicePrincipal -filter "DisplayName eq 'Power BI Service'" -Verbose #Define policy for 23 hours $policy = New-AzureADPolicy -Definition @('{"TokenLifetimePolicy":{"Version":1,"AccessTokenLifetime":"23:00:00"}}') -DisplayName "PowerBI-access-token-Policy" -IsOrganizationDefault $false -Type "TokenLifetimePolicy" # Get ID of the service principal $sp = Get-AzureADServicePrincipal -Filter "DisplayName eq 'Power BI Service'" # Assign policy to the id of the service principal found in the previous step Add-AzureADServicePrincipalPolicy -Id $sp.ObjectId -RefObjectId $policy.id
Hi Anonymous Anonymous
I've created in another post a related but different topic you could give me a hand with and I'd make you a monument!
Here is the post:
https://community.powerbi.com/t5/Developer/Refresh-the-token-in-PowerBI-Embedded/m-p/2548512#M36427