Fix Power Query Cannot Authenticate to Azure AD REST API
Question details
The user is unable to authenticate Power Query to an Azure AD secured REST API due to an invalid audience error, even though the same API URL works successfully in a web browser.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Connecting Power Query to a custom REST service secured by Azure Active Directory.
- Observed behavior
- Power Query fails to authenticate and reports an invalid audience error because the Azure AD access token was issued for a different API or resource than the REST service expects.
Ensure you have administrative access to the Azure Portal and sufficient permissions to view or modify App Registrations, API scopes, and application consent settings.
Verify Application ID URI and Token Audience
Check that the access token's audience (aud claim) perfectly matches the Application ID URI expected by the REST API.
When Power Query requests an access token from Azure AD, it specifies a resource. If this resource does not match the exact Application ID URI configured in the API's app registration, the resulting token will have an invalid audience claim, causing the REST API to reject the connection.
Log in to the Azure Portal, navigate to Azure Active Directory, and select App registrations. Find and open the registration for your REST API.
Navigate to the 'Expose an API' blade and note the exact Application ID URI. This is the identifier the token must be issued for.
Check your Power Query Web.Contents configuration to ensure the 'Resource' parameter exactly matches the Application ID URI found in Azure.
If you are able to capture the token being sent by Power Query, decode it using a JWT decoder tool to verify that the 'aud' claim matches your API's Application ID URI.

Review API Scopes and Admin Consent Settings
Ensure the client application has been granted the necessary permissions to access the REST API and that consent is properly configured.
Escalate to Developer Support Communities
If all Azure app registration settings appear correct but the invalid audience error persists, escalate the specific configuration details to specialized support channels.
Try WPS Office for Your Data Management Needs
If you are tired of dealing with complex Microsoft Office integration issues or backend authentication setups, consider WPS Office. It provides a highly compatible, lightweight, and free alternative to Excel for most data analysis, spreadsheet management, and reporting tasks.
- 1. Download the software: Visit the official WPS Office website and download the free installer for your operating system.
- 2. Install WPS Office: Run the installer and follow the on-screen prompts to set up the software in just a few clicks.
- 3. Open your workbooks: Launch WPS Spreadsheet and open your existing Excel data files directly to continue your analysis seamlessly.

Frequently Asked Questions
Why does the Azure AD REST API work in my web browser but fail in Power Query?
Web browsers and Power Query request access tokens differently. The browser usually requests a token intended for a web frontend application, while Power Query requests a token for the backend REST API directly. If the token audiences do not match, Power Query receives an invalid audience error.
How do I fix the invalid audience error in Power Query?
You need to ensure that the App Registration for your API in Azure exposes the correct Application ID URI, and that your Power Query configuration specifically requests a token using that exact URI as the resource.
What tool can I use to inspect my Azure AD access token?
You can use a proxy tool to capture the Bearer token being sent by Power Query, and then paste that token string into a JWT decoding website like jwt.ms to safely inspect the 'aud' (audience) claim without exposing your credentials.




