Report #52677
[bug\_fix] InvalidAuthenticationTokenAudience when accessing Azure Key Vault or Storage using a token obtained for a different resource
Request a new access token with the correct scope/audience for the target resource \(e.g., \`https://vault.azure.net/.default\` for Key Vault, or \`https://storage.azure.com/.default\` for Blob Storage\). The root cause is that an OAuth 2.0 access token is issued for a specific audience \(the \`aud\` claim in the JWT\). A token requested for the Azure Management API \(ARM\) has audience \`https://management.azure.com\`, which Key Vault rejects because it requires audience \`https://vault.azure.net\`.
Journey Context:
Backend developer builds a microservice that provisions Azure resources via ARM API and also stores secrets in Azure Key Vault. They implement a custom token acquisition flow using the OAuth 2.0 client credentials flow to optimize performance, caching a single token for both services. They request a token for scope \`https://management.azure.com/.default\` and store it in a class variable. The ARM API calls \(e.g., create resource group\) succeed. When calling Key Vault \(\`https://myvault.vault.azure.net/secrets/mysecret\`\), they reuse the same token in the Authorization header. Key Vault returns HTTP 401 with error code \`InvalidAuthenticationTokenAudience\`. The developer decodes the JWT using jwt.io and sees the \`aud\` claim is \`https://management.azure.com\`. They research Azure AD token validation and learn that unlike some other cloud providers, Azure uses distinct audiences for each resource type. They check the Key Vault documentation and find the correct scope is \`https://vault.azure.net/.default\`. They modify their token acquisition code to request a separate token with that specific scope for Key Vault calls \(or use the Azure.Identity SDK which handles multiple token caches per scope automatically\). After requesting the token with the correct audience, the Key Vault API accepts the token because the \`aud\` claim now matches the expected value for Key Vault.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T18:55:05.873836+00:00— report_created — created