Forum Discussion
401 Unauthorized response when fetching an embed token for Power BI
I followed the article listed here https://learn.microsoft.com/en-us/power-bi/developer/embedded/embed-service-principal
I then wrote a C# console application that first generates an access token and then generates an embed token using the Power BI Nuget library method GetReportInGroupAsync
However, this method throws an Unauthorized error. I printed the response data and saw the following header;
X-PowerBI-Error-Info: ServicePrincipalIsNotAllowedByTenantAdminSwitch
My Power BI admin has already enabled this setting in the Power BI Admin Portal and the security group that contains my service principal is added to the list of groups for which access is allowed.
What am I missing?
- Anonymous2 years ago
Hi aaronfdsouza ,
Base on your description, it seems you’re encountering an unauthorized error while fetching an embed token for Power BI using a service principal. Could you please refer the following official documentations and check the following info?
Embed Token - Generate Token - REST API (Power BI Power BI REST APIs) | Microsoft Learn
1. Ensure the service principal have the proper permissions
- Ensure that the service principal (app registration) has the necessary permissions in Azure AD. It should have the "API permissions" for Power BI Service.
- Enable the Service Principal option in the Power BI Admin Portal
- Add the service principal to the Power BI workspace security group.
2. Make sure that input the correct info for Organization Tenant ID, Client ID and Secret parameter values
Get the embedding parameter values
3. Check if it hit any following limitations
Considerations and limitations
Best Regards
2 Replies
- AnonymousNot applicable
Hi aaronfdsouza ,
Base on your description, it seems you’re encountering an unauthorized error while fetching an embed token for Power BI using a service principal. Could you please refer the following official documentations and check the following info?
Embed Token - Generate Token - REST API (Power BI Power BI REST APIs) | Microsoft Learn
1. Ensure the service principal have the proper permissions
- Ensure that the service principal (app registration) has the necessary permissions in Azure AD. It should have the "API permissions" for Power BI Service.
- Enable the Service Principal option in the Power BI Admin Portal
- Add the service principal to the Power BI workspace security group.
2. Make sure that input the correct info for Organization Tenant ID, Client ID and Secret parameter values
Get the embedding parameter values
3. Check if it hit any following limitations
Considerations and limitations
Best Regards
- MurugeshPeurmalNew Member
i am also having simuler issue and all the required rights has been provided. still i am facing an issue .
Now from our code we did following below steps:
1. Get access token from Microsoft entra for service principal - success
2. Generate token for the report inside the workspace - every time fails here, even with different methods