cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
maimon
New Member

Custom connector with OAuth - Fails to obtain data through Azure API Management

Hello,

 

I have an AAD-protected API exposed through API Management. I am able to access the API directly with a custom connector, but not when the API is placed behind API Management. (API Management does not use OAuth itself, it only contains some inbound token validation.)

 

Running a test on the custom connector does not give any information about the underlying problem, because the connector returns HTTP 200, no error, but with no data. Since the API does return data, behind the HTTP 200 there must be some error. The only thing I change in the connector between the two scenarios is the API vs API Management hostname.

 

With a local client I can access both the API and API Management successfully (using just the API in production is in this case not an option).

 

How to troubleshoot this given the absence of any error message?

 

Thanks

Pat

1 ACCEPTED SOLUTION

Accepted Solutions

Thank you, the problem is fixed by accepting https://flow.microsoft.com as CORS origin on APIM.

 

Best regards.

View solution in original post

6 REPLIES 6
v-xida-msft
Community Support
Community Support

Hi @maimon ,

Based on the issue that you mentioned, I think the Azure API Management policy in custom connector in PowerApps could achieve your needs.

please check the following article for more details:

https://docs.microsoft.com/en-us/power-platform-release-plan/2019wave2/cdm-data-integration/support-...

 

More details about Policy template supported in PowerApps custom connector, please refer to the following article:

https://docs.microsoft.com/en-us/connectors/custom-connectors/policy-templates

 

According to the scenario that you mentioned, I think you could consider configure a Route Request template policy within you custom connector. When you call the action path under your API Management, it would be routed to access underlying API to obtain data.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi, 

 

thank you. I tried that but APIM still receives the same request and returns the same result. I'm adding the Events relative path, see attachments.

 

Regards

 

 

Hi @maimon ,

Do you create a custom connector based on your Azure API Management directly?

 

If you created a custom connector based on your Azure API Management directly, I afraid that there is no way to achieve your needs. The Azure API Management policy in customer connector is used to transform and protect your underlying REST API. You could not use the Azure API Management policy in customer connector within PowerApps to apply changes to the Azure API Management.

 

So please consider create a custom connector based on your underlying REST API, and then use the Azure API Management policy to transfer and protect your underlying REST API.

 

Please check and see the following article about Azure API Management:

https://docs.microsoft.com/en-us/azure/api-management/transform-api

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-xida-msft 

 

thanks. We found that API Management won't forward the call to the backend because of the CORS policies:

               <allowed-origins>

                       <origin>*</origin>

               </allowed-origins>

fixes the problem. It is not clear, however, why a call from Power Apps is blocked by a CORS policy and which hosts should be allowed for Power Apps.

 

Hi @maimon ,

Based on the issue that you mentioned, I think this issue is related to your Azure Function rather than PowerApps Itself.

 

On your side, you should configure proper CORS policy for your Azure function. More details about configuring a CORS policy for Azure function, please check the following article:

https://john-liu-ppph.squarespace.com/?offset=1508250325583&category=AzureFunctions

 

More details about hosted allowed for PowerApps, please check the following article:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/limits-and-config#required-services

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you, the problem is fixed by accepting https://flow.microsoft.com as CORS origin on APIM.

 

Best regards.

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,537)