How to protect an API in Azure APIM using Azure Active Directory.

This article is intended to summarize a very common scenario where we would like to authenticate an API using OAuth2.0 authentication using azure AD and Azure API Management. There exist a simple and easy way to do the same. Here’re the steps,

We need to make two applications inside Azure Active Directory. In this case I am naming these as EchoBackend (your Backend API which is a web application) and Testclientapp(The Client API which is a native app). I am mentioning the steps assuming you are familiar in making applications in azure AD and with the Publisher and Developer portal of azure APIM.


  1. Make EchoBackend application with the help of following information: [Type: Web Application]
    1. Name: EchoBackend
    2. Sign-On-Url:
    3. Client ID: xxxxxxxx-50ad-4a34-a4ed-63f7ff4ae762 (assuming)
    4. App Id Uri:
    5. Add permissions: 1- read directory data 2- sign in and read user profile.


  1. Make Testclientapp application with following parameters: [Type: Native App]
    1. Name: Testclientapp
    2. Client ID: yyyyyyyy-5659-4cf6-87bd-ad8d176521d2 (assuming)
    3. redirectURI: (can be taken from the publisher portal with respect to your API or for time being it can be anything)
    4. Add Permission: 1- Access echo backend 2-Check the last permission.


  1. Change the security to OAuth2.0 in developer portal:
    1. Make Authorization end point url:
    2. Add one Additional body parameters named resource with value web app Uri-  resource :
    3. Client authentication method: basic
    4. Clinet ID: yyyyyyyy-5659-4cf6-87bd-ad8d176521d2
    5. Authorization endpoint url and Token endpoint URL: as per AD tenant.
    6. Use the redirect_uri as testclientapp.

Please refer following article documenting more details:


Hope this simplifies the understanding.

Happy Coding!