Forum Discussion
How to Power Query with Excel and Organizational account?
- 6 months ago
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-authenticationPower Query custom connector authentication (OAuth flow basics)
https://learn.microsoft.com/en-us/power-query/handling-authenticationGuidance on configuring Microsoft Entra (Azure AD) for custom connectors
https://learn.microsoft.com/en-us/power-query/configure-microsoft-entra-for-connector
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