Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
ragnew
Regular Visitor

'Forbidden' status when using Embedded report with SQL Analysis Service, Service Principal and AppOw

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.

 

https://learn.microsoft.com/en-us/power-bi/developer/embedded/sql-server-analysis-services-embed?tab...

 

/// <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"}}

0 REPLIES 0

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.