I'm trying to embed a powerbi report in a .NET Core Project with RLS(row level security)
The issue is I'm unable to add the reference to the embedToken on the front end.
Here is the front end code:
<script type="text/javascript">
// This code is for sample purposes only.
// Configure IFrame for the Report after you have an Access Token.
window.onload = function () {
var reportData = @Html.Raw(Json.Serialize(Model));
var accessToken = reportData.AccessToken;
var embedUrl = reportData.EmbedUrl;
var reportId = reportData.ReportId;
//show panel for admins
if (userIsAdmin == "true") {
filterPaneEnabled = true;
}
else {
filterPaneEnabled = true;
}
var config = {
type: 'report',
accessToken: accessToken,
embedUrl: embedUrl,
tokenType: models.TokenType.Embed,
id: reportId,
settings: {
filterPaneEnabled: filterPaneEnabled,
navContentPaneEnabled: true
}
};
// Grab the reference to the div HTML element that will host the report.
var reportContainer = document.getElementById('reportContainer');
// Embed the report and display it within the div container.
var report = powerbi.embed(reportContainer, config);
};
</script>
Here is the backend token generation by providing effective identity/role for rls:
var rls = new EffectiveIdentity(username: "someuser", new List<string> { "someid" });
var rolesList = new List<string>();
rolesList.Add("DYNAMIC_RLS");
rls.Roles = rolesList;
var embedToken = client.Reports.GenerateTokenInGroup(groupId, reportId,
new GenerateTokenRequest(accessLevel: "View", datasetId: "someid", rls));
EmbedToken token = await GetEmbedToken(client, reportId, groupId, accessToken);
Report powerBIReport;
powerBIReport = await GetPowerBIReport(client, reportId, groupId);
if (powerBIReport != null)
{
model.ReportId = reportId;
model.ReportName = report.Name;
model.EmbedToken = token;
model.AccessToken = accessToken;
model.EmbedUrl = powerBIReport.EmbedUrl;
model.UserIsAdmin = "false";
}
Here are the errors I'm getting: I noticed if I remove " tokenType: models.TokenType.Embed" from the front end config the report renders but no rls is shown.
Any tips? I have verified the embed token is generated correctly as I connected via powerbi sandbox environment!