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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
albertino_87
New Member

How to Power Query with Excel and Organizational account?

Hello, I have a local app running on http://localhost:5000 and the apis are protected with bearer authentication. whenever I try to get access to an api from excel (Data -> From Web) using the organizational account, it lets me login but then I get the following error:Screenshot 2026-01-31 140808.png
This is my configuration on Azure:
Screenshot 2026-01-31 115353.png
Screenshot 2026-01-31 115447.png

Screenshot 2026-01-31 115529.pngTo an unauthorized api query my app responds with 401 and this www-authenticate in the headers: WWW-Authenticate: Bearer authorization_uri="https://login.microsoftonline.com/4867c96f-cd16-46fc-a579-e15b271291c1/oauth2/v2.0/authorize", client_id="api://f9c8b648-29d0-4c8d-a516-5bcaff2c2324", scope=access_as_user
It seems like Excel is completely ignoring the client_id in the www-authenticate header Many thanks

1 ACCEPTED SOLUTION
Shravan133
Super User
Super User

This is a limitation of Power Query.

Excel’s “Organizational account” authentication does not work properly with custom OAuth-protected APIs, especially when the API is running on localhost. Power Query ignores the client_id and scope returned in the WWW-Authenticate header and always requests a token for its own default audience. Your API then rejects the token, which is why this fails even though login succeeds.

There are really only two reliable fixes:

Fix 1: Use client credentials
Switch the API to client credentials flow and request the token directly in Power Query, then pass it in the Authorization header. This works in both Excel and Power BI, but it won’t give you per-user identity.

Fix 2: Use a Power Query custom connector
If you need user-based authentication, you’ll need to build a custom Power Query connector (.mez) and implement OAuth explicitly. This is the only supported way to control client_id, scope, and audience for a custom API.

Organizational account auth in Power Query is meant for Microsoft resources, not arbitrary protected APIs.

Authentication in desktop apps (covers how Power Query handles Azure AD / organizational account)
https://learn.microsoft.com/en-us/power-query/connector-authentication

Power Query custom connector authentication (OAuth flow basics)
https://learn.microsoft.com/en-us/power-query/handling-authentication

Guidance on configuring Microsoft Entra (Azure AD) for custom connectors
https://learn.microsoft.com/en-us/power-query/configure-microsoft-entra-for-connector



View solution in original post

6 REPLIES 6
v-ssriganesh
Community Support
Community Support

Hello @albertino_87,

We hope you're doing well. Could you please confirm whether your issue has been resolved or if you're still facing challenges? Your update will be valuable to the community and may assist others with similar concerns.

Thank you.

Hi @v-ssriganesh, well I haven't resolved the issue, I don't know how to create a custom connector but at least I know that it's not supposed to work as is.

Many thanks

Alberto 

Hello @albertino_87,

Please consider raising a Microsoft support ticket for further investigation. You can explain all the troubleshooting steps you have taken to help them better understand the issue.

You can create a Microsoft support ticket with the help of the link below:
https://learn.microsoft.com/en-us/power-bi/support/create-support-ticket

 

Hi @albertino_87, hope you are doing well. Just wanted to know if your issue has been resolved through your support ticket with Microsoft? If so, we would greatly appreciate it if you could share the insights here, as they may benefit others with similar issues. If you have any other queries, please feel free to raise a new post in the community. We are always happy to help. Thank you.

v-ssriganesh
Community Support
Community Support

Hi @albertino_87,

Thank you for posting your query in the Microsoft Fabric Community Forum, and thanks to @Shravan133 for sharing valuable insights.

 

Could you please confirm if your query has been resolved by the provided solution? If so, please mark it as the solution. This will help other community members solve similar problems faster.

Thank you.

Shravan133
Super User
Super User

This is a limitation of Power Query.

Excel’s “Organizational account” authentication does not work properly with custom OAuth-protected APIs, especially when the API is running on localhost. Power Query ignores the client_id and scope returned in the WWW-Authenticate header and always requests a token for its own default audience. Your API then rejects the token, which is why this fails even though login succeeds.

There are really only two reliable fixes:

Fix 1: Use client credentials
Switch the API to client credentials flow and request the token directly in Power Query, then pass it in the Authorization header. This works in both Excel and Power BI, but it won’t give you per-user identity.

Fix 2: Use a Power Query custom connector
If you need user-based authentication, you’ll need to build a custom Power Query connector (.mez) and implement OAuth explicitly. This is the only supported way to control client_id, scope, and audience for a custom API.

Organizational account auth in Power Query is meant for Microsoft resources, not arbitrary protected APIs.

Authentication in desktop apps (covers how Power Query handles Azure AD / organizational account)
https://learn.microsoft.com/en-us/power-query/connector-authentication

Power Query custom connector authentication (OAuth flow basics)
https://learn.microsoft.com/en-us/power-query/handling-authentication

Guidance on configuring Microsoft Entra (Azure AD) for custom connectors
https://learn.microsoft.com/en-us/power-query/configure-microsoft-entra-for-connector



Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 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