How to resolve MisMatchingOAuthClaims error while securing HTTP Request Trigger using Authorization in Azure Logic Apps?

Arjun Ramesh 46 Reputation points
2023-05-18T13:58:44.71+00:00

I have a Logic App "HTTP Request is Received Trigger" which is getting triggered by making a POST call in Azure Function. Currently I am only using the default SharedAccess Token. However I am trying to secure this using Authorization mechanism.

I have enabled OAuth policy in azure portal for the Logic App as shown below:User's image

Also, I am generating a token in C# code as shown below:

var credential = new DefaultAzureCredential();
var result = await credential.GetTokenAsync(new TokenRequestContext(new[] { "https://management.azure.com/.default" }));


var httpURL = "<loogic-app-URL>";
var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", result.Token);
var jsonData = System.Text.Json.JsonSerializer.Serialize(new
            {
                dummy_data = "<dummy-data>"
            });

await client.PostAsync(httpURL, new StringContent(jsonData.ToString(), Encoding.UTF8, "application/json"));

Here for generating the token, I have tried using the following endpoints:

  1. https://management.azure.com/.default
  2. https://logic.azure.com/.default

However, in both cases after getting the token, when making the POST call to Logic App URL I am getting claims mismatch error (as shown in the image below):

User's image

I had decoded the token being generated and could see that both "ISS" and "AUD" is same as that which has been configured in Azure portal mentioned above.

Could someone please suggest some solutions or point out what I could be potentially doing wrong here? I think I might be using the wrong access token endpoint here...

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,655 questions
Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,991 questions
{count} votes