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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
lkarolak
Frequent Visitor

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?

1 ACCEPTED SOLUTION

Thank you, @v-micsh-msft

 

I think I figured it out myself.

Since the users with which I shared the report were not members of the group, the line:

 

client.Reports.GetReportInGroup(GroupId, ReportId);

 

failed with 401 obviously, because the access to the group was denied.

 

Then I did this:

client.Reports.GetReports()

 

and from the list I received I filtered the report I needed and then it worked.

 

Thanks!

View solution in original post

2 REPLIES 2
v-micsh-msft
Microsoft Employee
Microsoft Employee

Try to switch the user token to 

Access token for non-Power BI users (app owns data)

This way should make the App be able to display reports correctly.

 

More information, please check:

Authenticate users and get an Azure AD access token for your Power BI App

 

Regards,

Michael

Thank you, @v-micsh-msft

 

I think I figured it out myself.

Since the users with which I shared the report were not members of the group, the line:

 

client.Reports.GetReportInGroup(GroupId, ReportId);

 

failed with 401 obviously, because the access to the group was denied.

 

Then I did this:

client.Reports.GetReports()

 

and from the list I received I filtered the report I needed and then it worked.

 

Thanks!

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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