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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
bwang1
New Member

Power BI API authorization issue through Office 365 group

We have a .NET Core application that embeds reports to web pages using the "User Owns Data" model. We assigned an Office 365 group as "Viewer" of the Workspace, but users of that group are getting 401 Unauthorized error when calling the GetReportInGroupAsync method. I assume users should get the "Viewer" permission through the group. How can we solve this problem? Thank you!

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @bwang1 ,

According to the error message, it seems that the "group" making the API call may not have sufficient privileges to access the reports. Make sure that  the "group" has been granted the appropriate permissions in Azure AD and Power BI. I found the following thread which has the similar problem as yours, hope it can help you solve the problem.

c# - Unauthorized response on GetReportInGroupAsync PowerBI Embedded API call using Service Principa...

For Service Principal to work for any embedding, you need to enable Service Principal option in Power BI Admin portal and then, add it to the Power BI workspace.

Please check the following once:

  1. Check if service principal is enabled under Admin portal in Power BI service. Follow step 3 onwards
  2. If things don't work for you after following the above step, try embedding with the developer sample

Besides, based on your code it looks like you are using ADAL library for authentication. Microsoft recommends to use MSAL library for authentication with Azure AD entities.
Also, you can use certificate instead of app secret for service principal authentication. (Docs)


Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-yiruan-msft
Community Support
Community Support

Hi @bwang1 ,

According to the error message, it seems that the "group" making the API call may not have sufficient privileges to access the reports. Make sure that  the "group" has been granted the appropriate permissions in Azure AD and Power BI. I found the following thread which has the similar problem as yours, hope it can help you solve the problem.

c# - Unauthorized response on GetReportInGroupAsync PowerBI Embedded API call using Service Principa...

For Service Principal to work for any embedding, you need to enable Service Principal option in Power BI Admin portal and then, add it to the Power BI workspace.

Please check the following once:

  1. Check if service principal is enabled under Admin portal in Power BI service. Follow step 3 onwards
  2. If things don't work for you after following the above step, try embedding with the developer sample

Besides, based on your code it looks like you are using ADAL library for authentication. Microsoft recommends to use MSAL library for authentication with Azure AD entities.
Also, you can use certificate instead of app secret for service principal authentication. (Docs)


Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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