Skip to content

Commit 8730069

Browse files
author
gitName
committed
draft
1 parent 90bd41e commit 8730069

File tree

3 files changed

+38
-28
lines changed

3 files changed

+38
-28
lines changed

articles/api-management/applications.md

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
---
2-
title: Create OAuth 2.0 application to access product APIs - Azure API Management
2+
title: Create OAuth 2.0 Application for Access to Product APIs - Azure API Management
33
titleSuffix: Azure API Management
44
description: Learn how to configure OAuth 2.0 application-based access to products in Azure API Management, including prerequisites and step-by-step guidance.
55
services: api-management
66
author: dlepow
77

88
ms.service: azure-api-management
99
ms.topic: how-to
10-
ms.date: 05/06/2025
10+
ms.date: 05/08/2025
1111
ms.author: danlep
1212
ms.custom:
1313
---
1414

15-
# Create and authorize access to products using OAuth 2.0 application
15+
# Register an OAuth 2.0 application for access to product APIs
1616

1717
[!INCLUDE [api-management-availability-premium-dev-standard-basic](../../includes/api-management-availability-premium-dev-standard-basic.md)]
1818

19-
API Management is introducing built-in OAuth 2.0 application-based access to products using the client credentials flow. API managers and developers can use applications to simplify securing access to APIs using OAuth 2.0 authorization.
19+
API Management now supports built-in OAuth 2.0 application-based access to product APIs using the client credentials flow. This feature allows API managers to register applications, streamlining secure API access for developers through OAuth 2.0 authorization.
2020

2121
With this feature:
2222

23-
* An API manager configures a product to use application based access, and registers a client application in Microsoft Entra ID that restricts access to the product's APIs.
24-
* Developers obtain application credentials from the developer portal to generate OAuth 2.0 tokens from Microsoft Entra ID.
25-
* A developer (or client app) can then use the OAuth 2.0 client credentials flow to obtain OAuth 2.0 tokens that are passed to the API Management gateway for authorization to the product's APIs.
23+
* API managers configure products in API Management to enable application-based access. They also register client applications in Microsoft Entra ID to limit access to specific products.
24+
* Developers access the developer portal to retrieve application credentials, which are used to secure access to product APIs.
25+
* Using the OAuth 2.0 client credentials flow, developers or client applications obtain tokens that are included in API requests. These tokens are validated by the API Management gateway to authorize access to the product's APIs.
2626

2727
> [!IMPORTANT]
2828
> This feature is in private preview. Ensure that you can create an API Management instance in an Early Updates Access Program (EUAP) region. See detailed [Prerequisites](#prerequisites).
2929
>
3030
3131
This article describes the following steps:
3232

33-
* Enable application-based access for a product in API Management
34-
* Create a client application in API Management that restricts access to the product
33+
* Enable application-based access for an API Management product
34+
* Create a client application that limits access to the product
3535
* View the client application in the developer portal and get credentials to the product's APIs
3636
* Test OAuth 2.0 token-based access to the product's associated API
3737

@@ -47,15 +47,17 @@ This feature enables:
4747

4848
## Prerequisites
4949

50-
- An API Management instance deployed in one of the Azure Early Updates Access Program (EUAP) regions, such as Central US EUAP. To create an API Management service instance, see [Create an API Management service instance](get-started-create-service-instance.md). The API Management instance must be in the **Premium**, **Standard**, **Basic**, or **Developer** tier.
50+
- An API Management instance deployed in one of the Azure Early Updates Access Program (EUAP) regions, such as Central US EUAP. If you need to deploy an instance, see [Create an API Management service instance](get-started-create-service-instance.md). The API Management instance must be in the **Premium**, **Standard**, **Basic**, or **Developer** tier.
5151

5252
> [!NOTE]
5353
> If you don't have access to an EUAP region, you can [request it](/troubleshoot/azure/general/region-access-request-process) through the Azure portal.
5454
55-
- At least one product in your API Management instance, with at least one API assigned to it. If you haven't yet created a product, see [Create and publish a product](api-management-howto-add-products.md).
56-
For testing, you can use the default **Starter** product and the **Echo** API that's added to it. The product should be in the **Published** state so that it can be accessed by developers through the developer portal.
55+
- At least one product in your API Management instance, with at least one API assigned to it.
56+
* The product should be in the **Published** state so that it can be accessed by developers through the developer portal.
57+
* For testing, you can use the default **Starter** product and the **Echo** API that's added to it.
58+
* If you want to create a product, see [Create and publish a product](api-management-howto-add-products.md).
5759

58-
- Sufficient permissions tenant to assign the **Application Administrator** role in Microsoft Entra, which requires at least the **Privileged Role Administrator** role.
60+
- Sufficient permissions tenant to assign the **Application Administrator** role in Microsoft Entra ID, which requires at least the **Privileged Role Administrator** role.
5961

6062
- Optionally, add one or more [users](api-management-howto-create-or-invite-developers.md) in your API Management instance.
6163

@@ -66,17 +68,14 @@ This feature enables:
6668
## Configure managed identity
6769

6870
1. Enable a system-assigned [managed identity for API Management](api-management-howto-use-managed-service-identity.md) in your API Management instance.
69-
70-
* Take note of the identity's **Object (principal) ID**.
71-
71+
7272
1. Assign the identity the **Application Administrator** RBAC role in Microsoft Entra ID. To assign the role:
7373

7474
1. Sign in to the portal and navigate to **Microsoft Entra ID**.
7575
1. In the left menu, select **Manage** > **Roles and administrators**.
7676
1. Select **Application administrator**.
7777
1. In the left menu, select **Manage** > **Assignments** > **+ Add assignments**.
78-
1. In the **Add assignments** pane, search for the API Management instance's managed identity by name or object (principal) ID, select it, and then select **Add**.
79-
78+
1. In the **Add assignments** pane, search for the API Management instance's managed identity by name (the name of the API Management instance), select it, and then select **Add**.
8079

8180
## Enable application based access for product
8281

@@ -115,7 +114,7 @@ Review application settings in **App registrations**:
115114

116115
## Create client application to access product
117116

118-
Now create a client application that is registered in Microsoft Entra ID and restricts access to one or more products.
117+
Now create a client application that is registered in Microsoft Entra ID and limits access to one or more products.
119118

120119
* A product must have **Application based access** enabled to be associated with a client application.
121120
* Each client application has a single user (owner) in the API Management instance that can access product APIs through the application.
@@ -129,20 +128,18 @@ Now create a client application that is registered in Microsoft Entra ID and res
129128
1. In the **Register an application** pane, enter the following application settings:
130129
* **Name**: Enter a name for the application.
131130
* **Owner**: Select the owner of the application from the dropdown list of users in the API Management instance.
132-
* **Grant access to selected products**: Select one or more products in the API Management instance that have **Application based access** enabled, such as the **Starter** product (see [Enable application based access for product](#enable-application-based-access-for-product)).
131+
* **Grant access to selected products**: Select one or more products in the API Management instance that you previously enabled for **Application based access**.
133132
* **Description**: Optionally enter a description.
134133

135134
:::image type="content" source="media/applications/register-application.png" alt-text="Screenshot of application settings in the portal.":::
136135
1. Select **Register**.
137136

138-
The application is added to the list of applications on the **Applications** pane. A client secret is automatically generated for the application. The client secret is used to obtain an OAuth token from the client application in the client credentials flow.
137+
The application is added to the list of applications on the **Applications** pane. A client secret is automatically generated for the application. The client secret is used to obtain an OAuth 2.0 token from the client application in the client credentials flow.
139138

140139
<!-- Where would client secret show? Should customer store it somewhere? -->
141140

142141
## Review client application settings
143142

144-
Review the settings for the client application in Microsoft Entra ID.
145-
146143
The application is named with the following format: **APIMApplication\<product-name\>**. For example, if the product name is **Starter**, the application name is similar to **APIMApplicationStarter**.
147144

148145
Review application settings in **App registrations**:
@@ -155,8 +152,7 @@ Review application settings in **App registrations**:
155152

156153
For example, if the client application grants access to the **Starter** product, the application has **Product.Starter.All** permissions to access the **APIMProductApplicationStarter** application.
157154

158-
<!-- Insert screenshot -->
159-
155+
:::image type="content" source="media/applications/client-api-permissions.png" alt-text="Screenshot of API permissions in the portal.":::
160156

161157
## List applications and get secrets in the developer portal
162158

@@ -193,15 +189,16 @@ $token = $response.access_token
193189

194190
### Call product API using token
195191

196-
The token generated in the previous step is used to call a product API. The token is passed in the **Authorization** header of the request. The API Management instance validates the token and authorizes access to the API. The following is an example call to the echo API.
192+
The token generated in the previous step is used to call a product API. The token is passed in the **Authorization** header of the request. The API Management instance validates the token and authorizes access to the API.
193+
194+
The following script shows an example call to the echo API.
197195

198196
```powershell
199197
200198
# Gatewate endpoint to call. Update with URI of API operation you want to call.
201199
$uri = "https://<gateway-hostname>/echo/resource?param1=sample"
202-
# $token is the token generated in the previous step.
203200
$headers = @{
204-
   "Authorization" = "Bearer $token"
201+
   "Authorization" = "Bearer $token" # $token is the token generated in the previous script.
205202
}
206203
$body = @{
207204
    "hello" = "world"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
$clientId = "b042cb8b-1fc2-41de-82bb-2f27878b3f30" # Client (application) ID of client application
2+
$clientSecret = "6t98Q~kZuv2qE105Xhj9HR7WYCw0Mrykat0nlad5" # Retrieve secret of client application in developer portal
3+
$scopeOfOtherApp = "api://af3845cb-c316-45ec-81f4-722187a9c6a3/.default" # Value of Audience in product properties
4+
$tenantId = "8390c86f-f232-4e60-9122-d5f42fda7481" # Your tenant id
5+
6+
$body = @{
7+
    grant_type    = "client_credentials"
8+
    client_id     = $clientId
9+
    client_secret = $clientSecret
10+
    scope         = $scopeOfOtherApp
11+
}
12+
$response = Invoke-RestMethod -Method Post -Uri "https://login.microsoftonline.com/$tenantId/oauth2/v2.0/token" -ContentType "application/x-www-form-urlencoded" -Body $body
13+
$token = $response.access_token
52.4 KB
Loading

0 commit comments

Comments
 (0)