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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors