Forum Discussion
Anonymous
6 years agoNot applicable
Set an expiry on embed token
When authorizing with a Workspace Collection, I could generate an embed token with an expiry (note the expiry argument):
public static Microsoft.PowerBI.Security.PowerBIToken CreateReportEmbedToken (string workspaceCollectionName, string workspaceId, string reportId, DateTime expiration, string username = null, System.Collections.Generic.IEnumerable<string> roles = null, string scopes = null);
It doesn't appear to be possible with Power BI Embedded:
public static System.Threading.Tasks.Task<Microsoft.PowerBI.Api.V2.Models.EmbedToken> GenerateTokenInGroupAsync (this Microsoft.PowerBI.Api.V2.IReports operations, string groupId, string reportKey, Microsoft.PowerBI.Api.V2.Models.GenerateTokenRequest requestParameters, System.Threading.CancellationToken cancellationToken = null);
Is there any way that I can create a longer-lived embed token?
1 Reply
- JayendranSolution Sage
Hi Anonymous ,
First of all Workspace Collection is be deprecated.
You couldn't directly control the expiration of the embed token from your code. However you can achieve that by changing overall access token life time in Azure Active Directory.
- Downloaded Azure AD PowerShell module Public Preview.
- Connect-AzureAD -Confirm with my azure subscription credentials to connect to my AAD organization account.
- New-AzureADPolicy -Definition @('{"TokenLifetimePolicy":{"Version":1,"AccessTokenLifetime":"10:00:00"}}') -DisplayName "myNewPolicy" -IsOrganizationDefault $true -Type "TokenLifetimePolicy"
Reference : https://stackoverflow.com/questions/50486248/power-bi-embedded-app-owns-data-changing-token-expiry