Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
The code snippet below works fine for a Generic Report which means with Internal Dataset, however If I try to GenerateToken for a Report with an External Dataset meaning a Dataset that lives in another Workspace it throws a 403 Forbidden.
Note: I'm using SPN to authenticate my request and SPN is an Admin of Both Workspace (Workspace where the External Dataset Lives and Workspace where the Report lives)
using (var pbiClient = await this.GetClientAsync().ConfigureAwait(false))
{
if (pbiClient != null)
{
var dataset = await pbiClient.Datasets.GetDatasetByIdInGroupAsync(groupId, datasetId).ConfigureAwait(false);
GenerateTokenRequest genereateTokenRequestParameters;
var identity = new EffectiveIdentity(user.Username.Trim(), new List<string> { dataset.Id })
{
Roles = new List<string> { securityRole }
};
genereateTokenRequestParameters = new GenerateTokenRequest(accessLevel: "view", identity: identity);
// THIS LINE OF CODE RETURNS 403 FOR REPORT WITH EXTERNAL DATASET,
// WHILE WORKS IF REPORT AND DATASET IS IN THE SAME WORKSPACE
var tokenResponse = await pbiClient.Reports.GenerateTokenInGroupAsync(reportGroupId, report.Id, genereateTokenRequestParameters).ConfigureAwait(false);
embedReport.EmbedToken = tokenResponse ?? throw new NullReferenceException($"Power BI token not generated. Report ID: {report.Id}");
embedReport.EmbedUrl = report.EmbedUrl;
embedReport.ReportId = report.Id;
return embedReport;
}
}
User | Count |
---|---|
14 | |
4 | |
2 | |
1 | |
1 |
User | Count |
---|---|
21 | |
3 | |
3 | |
2 | |
2 |