-1

I have integrated power-bi service(App Owns Data/service principle way) in my react.js App. Further I want to integrate RLS(Row Level Security) in the same. As mentioned in power-bi docs it is required to add c# code for embed token to generate and authenticate row level security.

c# code:

public EmbedToken GetEmbedToken(Guid reportId, IList<Guid> datasetIds, [Optional] Guid targetWorkspaceId)
{
    PowerBIClient pbiClient = this.GetPowerBIClient();

   // Defines the user identity and roles.
    var rlsIdentity = new EffectiveIdentity(
        username: "France",
        roles: new List<string>{ "CountryDynamic" },
        datasets: new List<string>{ datasetId.ToString()}
    );
   
    // Create a request for getting an embed token for the rls identity defined above
    var tokenRequest = new GenerateTokenRequestV2(
        reports: new List<GenerateTokenRequestV2Report>() { new GenerateTokenRequestV2Report(reportId) },
        datasets: datasetIds.Select(datasetId => new GenerateTokenRequestV2Dataset(datasetId.ToString())).ToList(),
        targetWorkspaces: targetWorkspaceId != Guid.Empty ? new List<GenerateTokenRequestV2TargetWorkspace>() { new GenerateTokenRequestV2TargetWorkspace(targetWorkspaceId) } : null,
        identities: new List<EffectiveIdentity> { rlsIdentity }
    );

    // Generate an embed token
    var embedToken = pbiClient.EmbedToken.GenerateToken(tokenRequest);

    return embedToken;
}
1
  • 1
    So what’s your question? Commented Nov 18, 2022 at 4:19

1 Answer 1

0

I achieved this using express.js and react.js

We need to get get Embed token using MSAL library(this can be done on server side only) and pass it on to client side using custom API call

by using embed token,client Id and power-bi embed client API we can generate report on client side

Sign up to request clarification or add additional context in comments.

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.