oauth-2.0azure-api-managementpower-automateapi-keypower-automate-custom-connector

Using Power Automate to connect to OAuth2 API through Azure API Management


I'm trying to set up the following workflow:

  1. Use Azure API Management to configure authentication to a 3rd-party API
  2. Use Power Automate to access data from 3rd-party API by passing through Azure API Management

I've been able to get the first part working. I have a developer portal set up, and from the portal I'm able to access the 3rd-party API. When attempting to access it, the portal prompts me for what type of authentication, and when I select "authorization code" (which is the one I configured), it correctly opens a prompt and asks me to authorize the connection, after which it provides me back the data as expected.

I'm unable to get the second part working, though. Using Azure API Management, I created a custom connector in Power Automate. When I went into the connectors in Power Automate to review the newly-created connector, I noticed that the authentication type it selected was API Key. When creating a connection using that connector, I was prompted with the same prompt as I described earlier. After providing authorization and then attempting to use the connector in a flow, I get the error "invalid token".

I have a feeling the reason why this is happening is because it's attempting to use the token that was generated when I initially authorized the connection, rather than requesting a new token when making the request. But I'm unsure of how to actually make that happen. I'd considered switching from API Key to OAuth2, but I can't find any documentation anywhere that explains how to use OAuth2 to authenticate through Azure API Management. The only documentation I can find refers to creating the connector in Power Automate using the OAuth2 credentials defined in the 3rd-party application - but that seems to completely skip over the first objective.

Any help or information is appreciated. Thanks!


Solution

  • Okay - so after some research, the conclusion is, using Authorizations solves pretty much all of the problems I was facing. Neato.