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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
aaronfdsouza
Frequent Visitor

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?

 

 

1 ACCEPTED SOLUTION
Anonymous
Not 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

Embed Power BI content in an embedded analytics application with service principal and an applicatio...

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.vyiruanmsft_2-1719390326278.png
  • Enable the Service Principal option in the Power BI Admin Portalvyiruanmsft_0-1719390243013.png
  • Add the service principal to the Power BI workspace security group.vyiruanmsft_1-1719390295441.png

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

vyiruanmsft_3-1719390781498.png

Best Regards

View solution in original post

1 REPLY 1
Anonymous
Not 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

Embed Power BI content in an embedded analytics application with service principal and an applicatio...

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.vyiruanmsft_2-1719390326278.png
  • Enable the Service Principal option in the Power BI Admin Portalvyiruanmsft_0-1719390243013.png
  • Add the service principal to the Power BI workspace security group.vyiruanmsft_1-1719390295441.png

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

vyiruanmsft_3-1719390781498.png

Best Regards

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.