Secure OAuth 2.0 Client Credentials in Azure Logic Apps with Key Vault
You are building an Azure Logic App that must call an external API secured with OAuth 2.0 Client Credentials flow. The external API is registered in a different Microsoft Entra ID tenant. You need to obtain an access token and add it to the request headers. Which action and authentication configuration should you use?
⚠ Common exam trap
Watch out — candidates often confuse Managed Identity with cross-tenant authentication, assuming it works across tenants, when in fact Managed Identity is strictly scoped to the resource's home tenant.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Use the HTTP action with Active Directory OAuth authentication, providing the tenant ID, client ID, and client secret.
The HTTP action's Active Directory OAuth authentication type directly supports the OAuth 2.0 Client Credentials flow for cross-tenant scenarios. By providing the tenant ID, client ID, and client secret, the Logic App runtime can obtain an access token from the external tenant's token endpoint and automatically inject it into the Authorization header as a Bearer token. This is the only built-in authentication option in the HTTP action that handles the client credentials grant without custom code.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Use the HTTP action with Managed Identity authentication.
Why it's wrong here
Managed Identities provide an identity for Azure resources to authenticate to services that support Microsoft Entra authentication within the same tenant where the identity is registered. Since the external API resides in a different Microsoft Entra ID tenant, the Logic App's Managed Identity would not be recognized or authorized by that external tenant's application registration, rendering it ineffective for cross-tenant API calls.
- ✗
Use the HTTP + Swagger connector to import the API definition.
Why it's wrong here
The HTTP + Swagger connector primarily serves to parse an OpenAPI (Swagger) definition, providing design-time schema validation and a more structured interface for the HTTP action within the Logic App. While it enhances the developer experience by defining API structure, it does not inherently handle the runtime acquisition or management of OAuth tokens, especially for complex cross-tenant authentication scenarios.
- ✓
Use the HTTP action with Active Directory OAuth authentication, providing the tenant ID, client ID, and client secret.
Why this is correct
This configuration correctly leverages the OAuth 2.0 Client Credentials flow, where the Logic App acts as a confidential client. By providing the external API's Microsoft Entra ID tenant ID, a registered application's client ID, and its corresponding client secret, the Logic App can directly request an access token from the external tenant's token endpoint. This token is then automatically attached to the HTTP request, authorizing access to the external API even across different tenants.
- ✗
Use the Azure Key Vault - Get secret action to retrieve a token.
Why it's wrong here
Azure Key Vault is a secure service for storing and managing secrets, keys, and certificates, such as API keys or client secrets. However, it is not designed to generate or store dynamic OAuth access tokens, which are short-lived credentials obtained from an identity provider after a successful authentication flow. The Logic App would still need to use stored client credentials to programmatically request a token from the external API's identity provider, not retrieve a pre-existing token from Key Vault.
Go deeper
Related to this question
About these practice questions
This AZ-204 question is part of Courseiva's 883-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
Same concept, more angles
3 more ways this is tested on AZ-204
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. You are building an Azure Logic App that must call a third-party REST API secured with OAuth 2.0 Client Credentials flow. The client ID and client secret are stored in Azure Key Vault. You need to securely obtain an access token and include it in requests to the API. Which approach should you use in the Logic App?
medium- A.Use the HTTP action with 'Active Directory OAuth' authentication and hardcode the client secret in the connection parameters.
- B.Create an Azure API connection (custom connector) with the OAuth 2.0 settings and store the secret in the connector's definition.
- ✓ C.Enable a system-assigned managed identity for the Logic App, grant it access to Key Vault, use the 'Get secret' action to retrieve the client secret into a variable, then use the HTTP action with 'Active Directory OAuth' authentication referencing that variable for the secret.
- D.Store the client secret in an Azure App Service application setting and reference it in the Logic App via a connector.
Why C: It securely retrieves the client secret from Azure Key Vault at runtime using a managed identity, avoiding any hardcoded secrets. The Logic App's system-assigned managed identity is granted access to Key Vault, then the 'Get secret' action fetches the secret into a variable, which is passed to the HTTP action's 'Active Directory OAuth' authentication. This approach follows the principle of least privilege and eliminates secret exposure in connection definitions or source code.
Variation 2. You are building an Azure Logic App that needs to call an external API secured with OAuth 2.0 client credentials flow. You have registered an application in Microsoft Entra ID with client ID 'myClientId' and client secret stored in Key Vault. Which action should you use to authenticate?
medium- ✓ A.HTTP action with Active Directory OAuth authentication
- B.HTTP action with Managed Identity authentication
- C.Invoke the API through Azure API Management
- D.Use the Microsoft Entra ID OAuth 2.0 connector
Why A: The HTTP action in Azure Logic Apps supports an 'Active Directory OAuth' authentication type that directly implements the OAuth 2.0 client credentials flow. By providing the tenant ID, client ID, and referencing the client secret from Key Vault (via a secure parameter or connection reference), the Logic App can obtain an access token from Microsoft Entra ID and authenticate to the external API without custom code.
Variation 3. You are building an Azure Logic App that calls an external REST API secured with the OAuth 2.0 client credentials flow. You have registered an app in Microsoft Entra ID with client ID and client secret stored in Azure Key Vault. The Logic App uses a system-assigned managed identity with Get permission on the secret. Which action should you use in the Logic App designer to authenticate to the API?
medium- ✓ A.HTTP action with 'Active Directory OAuth' authentication type, referencing the client ID and client secret
- B.HTTP action with 'Managed Identity' authentication type
- C.Invoke an API with OAuth predefined connector
- D.HTTP action with 'Basic' authentication and pass the secret as password
Why A: The OAuth 2.0 client credentials flow requires a client ID and client secret to obtain an access token from Microsoft Entra ID. The HTTP action's 'Active Directory OAuth' authentication type directly supports this flow, allowing you to reference the client ID and the client secret stored in Azure Key Vault. The Logic App's system-assigned managed identity has Get permission on the secret, enabling it to retrieve the secret at runtime without exposing it in the workflow definition.
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This AZ-204 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the AZ-204 exam.