Forum Discussion
Row Level Security Embedded Testing Options
- Anonymous2 years ago
Hi Kornholio1313 ,
When you're ready to embed the report into your app, you need to generate an embed token. To generate a token using the Embed Token API, pass the following information to the API.
- username (required) – If the roles are dynamic, the username string is used as the filter. For static roles, the username doesn't affect the RLS and can be any string at all. Only a single username can be listed.
- roles (required) – The role(s) used when applying Row Level Security rules. If passing more than one role, they should be passed as a string array.
- dataset (required) – The dataset that is applicable for the item you're embedding.
You can now embed the report into your app. The report filters data according to the RLS applied.
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: datasetIds.Select(id => id.ToString()).ToList()); ); // 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; }More detailed information can be found at the link:
If your Current Period does not refer to this, please clarify in a follow-up reply.
Best Regards,
Clara Gong
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Kornholio1313 ,
When you're ready to embed the report into your app, you need to generate an embed token. To generate a token using the Embed Token API, pass the following information to the API.
- username (required) – If the roles are dynamic, the username string is used as the filter. For static roles, the username doesn't affect the RLS and can be any string at all. Only a single username can be listed.
- roles (required) – The role(s) used when applying Row Level Security rules. If passing more than one role, they should be passed as a string array.
- dataset (required) – The dataset that is applicable for the item you're embedding.
You can now embed the report into your app. The report filters data according to the RLS applied.
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: datasetIds.Select(id => id.ToString()).ToList());
);
// 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;
}
More detailed information can be found at the link:
If your Current Period does not refer to this, please clarify in a follow-up reply.
Best Regards,
Clara Gong
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks Clara. So in my instance where would i put the name of the dataset below, mine is called 'portal'? My Role=Company Token. My username in the RLS is =()
- Kornholio13132 years agoFrequent Visitor
OK, i was able to generate the code, at least without RLS, but I am at the point where I need the HEAD and the BODY to enter in. From the Embed code i generated from the Power BI Embedded Playground, it doesnt show where to place that in the external URL for the HEAD and the BODY?