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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
jamesyoung
Frequent Visitor

Retrieve Roles API for generating token

When generating a token you now can pass in the Role(s) to use for RLS. How can you retrieve the Roles programmatically? Is that possible?

Here is how you generate a token using a role:

var generateTokenRequestParameters = new GenerateTokenRequest("View", null, identities: new List<EffectiveIdentity>
{ new EffectiveIdentity(username: "username", roles: new List<string> { "roleA", "roleB" }, datasets: new List<string> { "datasetId" }) });
var tokenResponse = await client.Reports.GenerateTokenInGroupAsync("groupId", "reportId", generateTokenRequestParameters);

https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-embedded-rls/

1 REPLY 1
Eric_Zhang
Microsoft Employee
Microsoft Employee


@jamesyoung wrote:

When generating a token you now can pass in the Role(s) to use for RLS. How can you retrieve the Roles programmatically? Is that possible?

Here is how you generate a token using a role:

var generateTokenRequestParameters = new GenerateTokenRequest("View", null, identities: new List<EffectiveIdentity>
{ new EffectiveIdentity(username: "username", roles: new List<string> { "roleA", "roleB" }, datasets: new List<string> { "datasetId" }) });
var tokenResponse = await client.Reports.GenerateTokenInGroupAsync("groupId", "reportId", generateTokenRequestParameters);

https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-embedded-rls/


@jamesyoung

AFAIK, it is not possible, there's no correlated REST API that can get RLS roles. You can check this idea REST API for managing roles of datasets and vote it up.

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.