Forum Discussion
Power Bi REST API - 401 Authorization error when using Service Principals
- 7 years ago
Hi Anonymous ,
I made the Service Principal work in the "App Owns Data" demo and with the Rest APIs. It seems everything is set up correctly according to your description. Some suggestions are as follows.
1. Add the Service Principal as an admin in the workspace directly rather than add the security group. Please refer to article 5 in embed-service-principal#get-started-with-a-service-principal. We should use the Object ID.
2. The Service Principal inherit permission from the tenant rather than the Azure App permissions.
>>>Service principals inherit the permissions for all Power BI tenant settings from their security group. To restrict permissions create a dedicated security group for service principals and add it to the 'Except specific security groups' list for the relevant, enabled Power BI settings.
3. I'm afraid you can't call the Admin REST API if the Service Principal doesn't have the permission.
Best Regards,
I was able to get the auth token by using the service principal (client id, secret) however when I use the token and query (getReports) etc, it fails with 401.
The trick to get the token was that the APP needs to be "Server-side web application" instead of "native".
However I believe the permissions are not being assigned when the app/security group is added to the Power BI API access.
- Anonymous7 years agoNot applicable
Then you're in the same situation as me :) I also manage to get the access token, but i can't use it.
- Anonymous5 years agoNot applicable
Make sure you target a new workspace and not the default "My Workspace" and check you have assigned all relevant permissions.
See my blog hope it helps : https://blog.joshduxbury.co.uk/2021/04/22/import-data-into-power-bi-using-rest-logic-apps/
- VSmart3 years agoFrequent Visitor
The same problem. Give all rights to app in Azure. Enable "Allow Service Principal to use Power BI APIs" but still get 401 Eror. Helpppp
- aechague3 years agoAdvocate II
Similar problem... I believe its related with the option Allow Service Principal to use Power BI APIs. on the PowerBI Tenant settings. That is mentioned that has to be activated in https://sqlitybi.com/authenticating-power-bi-xmla-endpoint-using-service-principal/