Skip to content

Commit 8c1ca96

Browse files
author
gitName
committed
metadata updates
1 parent 8c774cd commit 8c1ca96

28 files changed

+66
-62
lines changed
Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
2-
title: Protect API in API Management using OAuth 2.0 and Microsoft Entra ID
2+
title: Protect API in API Management - OAuth 2.0 and Microsoft Entra ID
33
titleSuffix: Azure API Management
44
description: Learn how to secure user access to an API in Azure API Management with OAuth 2.0 user authorization and Microsoft Entra ID.
55
services: api-management
66
author: dlepow
77
ms.service: azure-api-management
8-
ms.topic: article
9-
ms.date: 04/27/2022
8+
ms.topic: how-to
9+
ms.date: 02/20/2025
1010
ms.author: danlep
1111
---
1212

@@ -16,85 +16,93 @@ ms.author: danlep
1616

1717
In this article, you'll learn high level steps to configure your [Azure API Management](api-management-key-concepts.md) instance to protect an API, by using the [OAuth 2.0 protocol with Microsoft Entra ID](../active-directory/develop/active-directory-v2-protocols.md).
1818

19-
For a conceptual overview of API authorization, see [Authentication and authorization to APIs in API Management](authentication-authorization-overview.md).
19+
For a conceptual overview of API authorization options in API Management, see [Authentication and authorization to APIs in API Management](authentication-authorization-overview.md).
2020

2121
## Prerequisites
2222

2323
Prior to following the steps in this article, you must have:
2424

2525
- An API Management instance
2626
- A published API using the API Management instance
27-
- A Microsoft Entra tenant
27+
- A Microsoft Entra tenant where you have permissions to create an app regisgtration
2828

2929
## Overview
3030

3131
Follow these steps to protect an API in API Management, using OAuth 2.0 authorization with Microsoft Entra ID.
3232

33-
1. Register an application (called *backend-app* in this article) in Microsoft Entra ID to protect access to the API.
34-
35-
To access the API, users or applications will acquire and present a valid OAuth token granting access to this app with each API request.
36-
37-
1. Configure the [validate-jwt](validate-jwt-policy.md) policy in API Management to validate the OAuth token presented in each incoming API request. Valid requests can be passed to the API.
38-
39-
Details about OAuth authorization flows and how to generate the required OAuth tokens are beyond the scope of this article. Typically, a separate client app is used to acquire tokens from Microsoft Entra ID that authorize access to the API. For links to more information, see the [Next steps](#next-steps).
40-
41-
<a name='register-an-application-in-azure-ad-to-represent-the-api'></a>
33+
1. Register an application (called *backend-app* in this article) in Microsoft Entra ID to represent the API.
34+
1. Register an application to represent the client app that calls the API and that obtains tokens from Microsoft Entra ID. This step is not covered in this article because the configuration is dependent on the
35+
1. Configure the [validate-azure-ad-token](validate-azure-ad-token-policy.md) policy in API Management to validate the OAuth token presented in each incoming API request. Requests with valid tokens are passed to the backend API. Depending on your scenario, your backend API could independently validate the token.
4236

4337
## Register an application in Microsoft Entra ID to represent the API
4438

45-
Using the Azure portal, protect an API with Microsoft Entra ID by first registering an application that represents the API.
39+
Using the Azure portal, first register an application that represents the API.
4640

47-
For details about app registration, see [Quickstart: Configure an application to expose a web API](../active-directory/develop/quickstart-configure-app-expose-web-apis.md).
41+
For details about app registration, see [Quickstart: Configure an application to expose a web API](/entra/identity-platform/quickstart-configure-app-expose-web-apis).
4842

4943
1. In the [Azure portal](https://portal.azure.com), search for and select **App registrations**.
5044

51-
1. Select **New registration**.
45+
1. Select **+ New registration**.
5246

53-
1. When the **Register an application page** appears, enter your application's registration information:
47+
1. On the **Register an application** page, enter your application's registration information:
5448

55-
- In the **Name** section, enter a meaningful application name that will be displayed to users of the app, such as *backend-app*.
49+
- In the **Name** section, enter a meaningful application name that is displayed to users of the app, such as *backend-app*.
5650
- In the **Supported account types** section, select an option that suits your scenario.
5751

58-
1. Leave the [**Redirect URI**](../active-directory/develop/reply-url.md) section empty.
52+
1. Leave the [**Redirect URI**](/entra/identity-platform/reply-url) section empty.
5953

6054
1. Select **Register** to create the application.
6155

6256
1. On the app **Overview** page, find the **Application (client) ID** value and record it for later.
6357

64-
1. Under the **Manage** section of the side menu, select **Expose an API** and set the **Application ID URI** with the default value. If you're developing a separate client app to obtain OAuth 2.0 tokens for access to the backend-app, record this value for later.
58+
1. Under the **Manage** section of the side menu, select **Expose an API**. **Add** the **Application ID URI** with the default value. Record this value for later.
6559

66-
1. Select the **Add a scope** button to display the **Add a scope** page:
67-
1. Enter a new **Scope name**, **Admin consent display name**, and **Admin consent description**.
60+
1. On the **Expose an API** page, select **+ Add a scope** to display the **Add a scope** page.
61+
1. Enter a new **Scope name** for a scope that's supported by the API (for example, **Files.Read**).
62+
1. In **Who can consent?**, make a selection for your scenario, such as **Admins and users**. Select **Admins only** for higher privileged environments.
63+
1. Enter **Admin consent display name** and **Admin consent description**.
6864
1. Make sure the **Enabled** scope state is selected.
65+
1. Select **Add scope** to create the scope.
6966

70-
1. Select the **Add scope** button to create the scope.
71-
72-
1. Repeat the previous two steps to add all scopes supported by your API.
67+
1. Repeat the previous step to add all scopes supported by your API.
7368

7469
1. Once the scopes are created, make a note of them for use later.
7570

76-
## Configure a JWT validation policy to pre-authorize requests
71+
72+
## Register an application in Microsoft Entra ID to represent the client app
73+
74+
While not shown in this article, in most scenarios you would register a second application in Microsoft Entra ID (*client-app*) to represent a client application that calls the API. The app registration must have permissions to call the backend app. Details about app registration are specific to your scenario.
75+
76+
Configure the client application to use Microsoft Entra ID to request valid OAuth tokens granting access to the API. Present the token in the request to API Management (for example, in an Authorization header).
77+
78+
Development of a client application that uses Microsoft Entra ID to request valid OAuth tokens is beyond the scope of this article and specific to your scenario. For examples and guidance, see [Microsoft identity platform code samples](entra/identity-platform/sample-v2-code).
79+
80+
81+
## Configure a token validation policy to preauthorize requests
7782

7883
[!INCLUDE [api-management-configure-validate-jwt](../../includes/api-management-configure-validate-jwt.md)]
7984

85+
8086
## Authorization workflow
8187

82-
1. A user or application acquires a token from Microsoft Entra ID with permissions that grant access to the backend-app. If you use the v2 endpoint, ensure that the accessTokenAcceptedVersion property is set to 2 in the application manifest of the back end app and any client app that you configure.
88+
THe following steps make up a typical authorization workflow for an API in API Management that uses OAuth 2.0 authorization with Microsoft Entra ID.
89+
90+
1. A user or application acquires a token from Microsoft Entra ID with permissions that grant access to the backend-app. If you use the v2 endpoint, ensure that the accessTokenAcceptedVersion property is set to 2 in the application manifest of the backend-app and any client app that you configure.
8391

8492
1. The token is added in the Authorization header of API requests to API Management.
8593

86-
1. API Management validates the token by using the `validate-jwt` policy.
94+
1. API Management validates the token by using the `validate-azure-ad-token` policy.
8795

8896
* If a request doesn't have a valid token, API Management blocks it.
8997

9098
* If a request is accompanied by a valid token, the gateway can forward the request to the API.
9199

92-
## Next steps
100+
## Related content
93101

94102
* To learn more about how to build an application and implement OAuth 2.0, see [Microsoft Entra code samples](../active-directory/develop/sample-v2-code.md).
95103

96104
* For an end-to-end example of configuring OAuth 2.0 user authorization in the API Management developer portal, see [How to authorize test console of developer portal by configuring OAuth 2.0 user authorization](api-management-howto-oauth2.md).
97105

98106
- Learn more about [Microsoft Entra ID and OAuth2.0](../active-directory/develop/authentication-vs-authorization.md).
99107

100-
- For other ways to secure your back-end service, see [Mutual certificate authentication](./api-management-howto-mutual-certificates.md).
108+
- Learn more about [authentication and authorization options](authentication-authorization-overview.md) in API Management.

articles/api-management/api-management-terminology.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services: api-management
55
author: dlepow
66
manager: cfowler
77
ms.service: azure-api-management
8-
ms.topic: article
8+
ms.topic: concept-article
99
ms.date: 05/09/2022
1010
ms.author: danlep
1111
---

articles/api-management/automation-manage-api-management.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ author: dlepow
66
manager: eamono
77
ms.assetid: 2e53c9af-f738-47f8-b1b6-593050a7c51b
88
ms.service: azure-api-management
9-
ms.topic: article
9+
ms.topic: concept-article
1010
ms.date: 02/13/2018
1111
ms.author: danlep
1212
---

articles/api-management/configure-graphql-resolver.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services: api-management
55
author: dlepow
66

77
ms.service: azure-api-management
8-
ms.topic: article
8+
ms.topic: how-to
99
ms.date: 05/02/2024
1010
ms.author: danlep
1111
---

articles/api-management/diagnose-solve-problems.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Azure API Management Diagnose and solve problems
33
description: Learn how to troubleshoot issues with your API in Azure API Management with the Diagnose and Solve tool in the Azure portal.
44
author: dlepow
55
ms.service: azure-api-management
6-
ms.topic: article
6+
ms.topic: how-to
77
ms.date: 02/05/2021
88
ms.author: danlep
99
---

articles/api-management/edit-api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Learn how to use API Management to edit an API. Add, delete, or ren
44
services: api-management
55
author: dlepow
66
ms.service: azure-api-management
7-
ms.topic: article
7+
ms.topic: how-to
88
ms.date: 01/19/2022
99
ms.author: danlep
1010
---

articles/api-management/how-to-configure-cloud-metrics-logs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services: api-management
55
author: dlepow
66
manager: gwallace
77
ms.service: azure-api-management
8-
ms.topic: article
8+
ms.topic: how-to
99
ms.date: 04/30/2020
1010
ms.author: danlep
1111
---

articles/api-management/how-to-configure-local-metrics-logs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services: api-management
55
author: dlepow
66
manager: gwallace
77
ms.service: azure-api-management
8-
ms.topic: article
8+
ms.topic: how-to
99
ms.date: 04/12/2024
1010
ms.author: danlep
1111
---

articles/api-management/how-to-configure-service-fabric-backend.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ metadata:
88
- ge-structured-content-pilot
99

1010
ms.service: azure-api-management
11-
ms.topic: article
11+
ms.topic: how-to
1212
ms.date: 01/29/2021
1313
ms.author: danlep
1414
title: |

articles/api-management/how-to-deploy-self-hosted-gateway-azure-arc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ author: dlepow
55
ms.author: danlep
66
ms.service: azure-api-management
77
ms.custom: devx-track-azurecli
8-
ms.topic: article
8+
ms.topic: how-to
99
ms.date: 06/12/2023
1010
---
1111

0 commit comments

Comments
 (0)