Embedding report - unauthorized when report is shared
This is the scenario we have: an ASP.net application in which the users are authenticated via Azure AD. This application should embed a report from Power BI service. The report is in a premium capacity workspace.
When a user is a member of the workspace (with view permissions only), then the embedding works correctly, the token is retrieved and the report is displayed in out ASP.net webapp.
However, when the user is not a member of the workspace, but I have shared the report with the user using the "Share" functionality in Power BI, then I am getting 401 Unauthorized when trying to get the embed token for this report.
This is the code I am using:
using (var client = new PowerBIClient(new Uri(ApiUrl), tokenCredentials))
// this is where the exception (401) happens...
report = client.Reports.GetReportInGroup(GroupId, ReportId);
// further code...
When I open the report in the Power BI service, I can see it correctly...only the embedding fails.
Is there a possibility to embed a report , when it's "only" shared?