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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.