The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hi,
I've been building an AppOwnsData app using Service Principal to embed a series of reports that get data from an SQL Analysis Service with a live connection. I built the embed app using this https://learn.microsoft.com/en-us/power-bi/developer/embedded/embed-sample-for-customers?tabs=net-co... and the .NET core section here https://github.com/microsoft/PowerBI-Developer-Samples
When I run this using a sample dataset everything runs fine, so I'm sure my Azure AD is set up correctly. Additionally, when I run my Analysis service in my workspace app(?) from app.power.com everything works fine. The issue is coming from the embedding. The only change I made to the provided code was to include this, though I suspect this isn't the full solution. Without this change in code I get a "Bad Request" status, with this code it changes to "Forbidden" and returns this message. I've tried multiple combinations for username, some of which yield slightly different results, but all are forbidden.
I am admin or owner on everything Power BI in my organization.
/// <summary>
/// Get Embed token for single report, multiple datasets, and an optional target workspace
/// </summary>
/// <returns>Embed token</returns>
/// <remarks>This function is not supported for RDL Report</remakrs>
public EmbedToken GetEmbedToken(Guid reportId, IList<Guid> datasetIds, [Optional] Guid targetWorkspaceId)
{
PowerBIClient pbiClient = this.GetPowerBIClient();
// Define the user identity and roles. Use one of the following:
var rlsidentity = new EffectiveIdentity( // If no RLS
username: "xxx@yyy.ca", // can also be username@contoso.com
datasets: datasetIds.Select(s => s.ToString()).ToList());
// Create a request for getting an embed token for the rls identity defined above
// This method works only with new Power BI V2 workspace experience
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;
}
{"error":{"code":"InvalidRequest","message":"Creating embed token for accessing dataset 294a4d83-2ff6-4119-ace3-xxxxxxxxx requires gateway admin or datasource override effective identity access right"}}
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the June 2024 Power BI update to learn about new features.
User | Count |
---|---|
9 | |
7 | |
1 | |
1 | |
1 |
User | Count |
---|---|
16 | |
10 | |
10 | |
8 | |
7 |