Search code examples
oauth-2.0power-automate

Add OAuth authentication for HTTP request triggers


Microsoft added a new capability - Add OAuth authentication for HTTP request triggers.

I've been trying to trigger the flow by using the @azure/msal-browser package and passing the accessToken received in the flow in the Authorization header (i.e. Bearer {accessToken}).

But I'm getting an error:

code: "MisMatchingOAuthClaims"
message: "One or more claims either missing or does not match with the open authentication access control policy."

What am I doing wrong?


Solution

  • I could get the token and trigger the OAuth HTTP URL successfully! Please follow the following steps!

    • Create a flow with an HTTP trigger. Who can trigger the flow?: "Any user in my tenant"

    • Create an app in AAD / Entra ID.

    • Add Power Automate in the API permissions. image

    • Add Claims. I added all the claims for the test request. But in the document, just a subset is required. image

    • Create a secret image

    • Fill the required parameters on the Postman Authentication tab.

    Type: OAuth 2.0

    Grant Type: Client Credential

    Access Token URL: https://login.microsoftonline.com/{{TenantID}}/oauth2/v2.0/token

    Client ID: {{Client ID}}

    Client Secret: {{Client Secret}}

    Scope: https://service.flow.microsoft.com//.default

    pay attention to the "//" in the Scope image

    • Get a new access token and include it as a Barear token in the header of the request you are sending to the URL of the OAuth HTTP trigger