Home > Back-end >  Azure API Management, single API accept AAD or subscription key
Azure API Management, single API accept AAD or subscription key

Time:02-10

Is it possible to have a single API in APIM that either accepts AAD token or subscription, based on what product it belongs to?

Default, this does not work, since unchecking "require subscription" on API-level will override setting product to require subscription.

So, I see two solutions.. create two APIs in APIM and place them in separate products (same backend), or write a custom policy. Is there a way to check context.Subscription.Key and match with the product subscriptions?

CodePudding user response:

Should be possible by adding your API to two products:

  • One with subscription requirement enabled
  • Another without subscription requirement enabled, but with validate-jwt policy added at product level to require AAD token
  • Related