Forum Discussion
Embedding Report in Web Application, Authentication Error
- 4 years ago
Hi, I managed to get it working by including the Azure App ID that I registred as a Member in the actual Power BI workspace.
Hi ian_coetzer ,
Based on the error message, it appears to be a permissions issue. Are you using embedded for customer solution? There are two threads here with the same problem as yours, you can refer to the solution there to solve your problem. Hope they can help you.
Unauthorized response on GetReportInGroupAsync PowerBI Embedded API call using Service Principal
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:
- Check if service principal is enabled under Admin portal in Power BI service. Follow step 3 onwards
- 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)
Status: Unauthorized (401) error while getting the reports from the workspace
I had exact the same issue, and I checked the API call's header X-PowerBI-Error-Info. What I found there was: ServicePrincipalIsNotAllowedByTenantAdminSwitch.
So, your's tenant's admin should switch on "Allow service principals to use Power BI APIs" and apply it to security group where Service Principal resides:
Best Regards