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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Kudoed Authors