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
Anonymous
Not 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 1
Jayendran
Solution Sage
Solution 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

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.