You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/api-center/authorize-api-access.md
+52-62Lines changed: 52 additions & 62 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,20 +4,20 @@ description: Learn how to configure access to APIs in the Azure API Center inven
4
4
author: dlepow
5
5
ms.service: azure-api-center
6
6
ms.topic: how-to
7
-
ms.date: 04/25/2025
7
+
ms.date: 04/28/2025
8
8
ms.author: danlep
9
9
ms.custom:
10
10
# Customer intent: As an API program manager, I want to store API authorization information in my API center and enable authorized users to test APIs in the API Center portal.
11
11
---
12
12
13
13
# Authorize access to APIs in your API center
14
14
15
-
You can configure settings to authorize access to APIs in your API center. These settings:
15
+
You can configure settings to authorize access to APIs in your [API center](overview.md). These settings:
16
16
17
-
* Enable API authentication using API keys or OAuth 2.0 authorization
17
+
* Enable API authentication using either API keys or OAuth 2.0 authorization
18
18
* Associate specific authentication methods with specific API versions in your inventory
19
19
* Manage authentication to API versions by designated users or groups through access policies
20
-
* Enable authorized users to test APIs directly in the API Center portal
20
+
* Enable authorized users to test APIs directly in the [API Center portal](set-up-api-center-portal.md)
21
21
22
22
> [!NOTE]
23
23
> This feature is currently in preview.
@@ -26,89 +26,64 @@ You can configure settings to authorize access to APIs in your API center. These
26
26
27
27
* An API center in your Azure subscription. If you haven't created one already, see [Quickstart: Create your API center](set-up-api-center.md).
28
28
29
-
* Register at least API in your API center. For more information, see [Tutorial: Register APIs in your API inventory](register-apis.md).
29
+
* Register at least one API in your API center. For more information, see [Tutorial: Register APIs in your API inventory](register-apis.md).
30
30
31
31
* Configure an environment and a deployment for the API. For more information, see [Tutorial: Add environments and deployments for APIs](configure-environments-deployments.md).
32
32
33
33
* Set up the API Center portal. For more information, see [Set up API Center portal](set-up-api-center-portal.md).
34
34
35
+
* An Azure key vault to store API keys or OAuth 2.0 client secrets. For steps to create a key vault, see [Create a Key Vault](/azure/key-vault/general/quick-create-portal). The key vault should use the Azure role-based access control (RBAC) permission model.
36
+
35
37
* (For OAuth 2.0 authorization using Microsoft Entra ID) Permissions to create an app registration in a Microsoft Entra tenant associated with your Azure subscription.
36
38
37
39
38
40
## Option 1: Configure settings for API key authentication
39
41
40
-
For an API that supports API key authentication, follow these steps to configure settings in your API center. The API key must be stored in Azure Key Vault, and access to the key vault is through your API center's managed identity.
41
-
42
-
### 1. Store secret in Azure Key Vault
43
-
44
-
To store the API key securely, use Azure Key Vault. You can create a new key vault or use an existing one, using the Azure portal, Azure tools, or Azure SDKs. Your key vault should use the Azure role-based access control (RBAC) permission model.
45
-
46
-
* For steps to create a key vault, see [Create a Key Vault](/azure/key-vault/general/quick-create-portal).
47
-
48
-
* To store the API key as a secret in the key vault, see [Set and retrieve secret in Key Vault](/azure/key-vault/secrets/quick-create-portal).
42
+
For an API that supports API key authentication, follow these steps to configure settings in your API center.
49
43
50
-
> [!NOTE]
51
-
> The *secret identifier* of the secret appears on the secret's details page. This is a URI of the form `https://<key-vault-name>.vault.azure.net/secrets/<secret-name>/<version>`. You need this value when you add the API key configuration in your API center.
44
+
### 1. Store API key in Azure Key Vault
52
45
53
-
### 2. Enable a managed identity in your API center
46
+
To manage the API key securely, store it in Azure Key Vault, and access the key vault using your API center's managed identity.
54
47
55
-
For this scenario, your API center uses a [managed identity](/entra/identity/managed-identities-azure-resources/overview) to access the keyvault. Depending on your needs, enable either a system-assigned or one or more user-assigned managed identities.
The following example shows how to enable a system-assigned managed identity by using the Azure portal. At a high level, configuration steps are similar for a user-assigned managed identity.
58
50
59
-
60
-
1. In the [portal](https://azure.microsoft.com), navigate to your API center.
61
-
1. In the left menu, under **Security**, select **Managed identities**.
62
-
1. Select **System assigned**, and set the status to **On**.
63
-
1. Select **Save**.
64
-
65
-
### 3. Assign the Key Vault Secrets User role to the managed identity
66
-
67
-
Assign your API center's managed identity the **Key Vault Secrets User** role in your key vault. The following steps use the Azure portal.
68
-
69
-
1. In the [portal](https://azure.microsoft.com), navigate to your key vault.
70
-
1. In the left menu, select **Access control (IAM)**.
71
-
1. Select **+ Add role assignment**.
72
-
1. On the **Add role assignment** page, set the values as follows:
73
-
1. On the **Role** tab, select **Key Vault Secrets User**.
74
-
1. On the **Members** tab, in **Assign access to**, select **Managed identity** > **+ Select members**.
75
-
1. On the **Select managed identities** page, select the system-assigned managed identity of your API center that you added in the previous section. Click **Select**.
76
-
1. Select **Review + assign** twice.
77
-
78
-
79
-
### 4. Add API key configuration in your API center
51
+
### 2. Add API key configuration in your API center
80
52
81
53
1. In the [portal](https://azure.microsoft.com), navigate to your API center.
82
54
1. In the left menu, under **Assets**, select **Authorization (preview)** > **+ Add configuration**.
83
-
1. In the **Add authorization** page, set the values as follows:
55
+
1. In the **Add configuration** page, set the values as follows:
56
+
:::image type="content" source="media/authorize-api-access/configure-api-key.png" alt-text="Screenshot of configuring an API key in the portal.":::
57
+
84
58
1. Enter a **Title** (name) and optional **Description** for the configuration.
85
59
1. In **Security scheme**, select **API Key**.
86
60
1. In **API key location**, select how the key is presented in API requests. Available values are **Header** (request header) and **Query** (query parameter).
87
61
1. In **API key parameter name**, enter the name of the HTTP header or query parameter that contains the API key. For example, `x-api-key`.
88
62
1. In **API key Key Vault secret reference**, enter the URI of the secret in your key vault that contains the API key. This is a URI of the form `https://<key-vault-name>.vault.azure.net/secrets/<secret-name>/<version>`.
89
63
1. Select **Create**.
90
64
65
+
:::image type="content" source="media/authorize-api-access/configure-api-key.png" alt-text="Screenshot of configuring an API key in the portal.":::
91
66
92
67
## Option 2: Configure settings for OAuth 2.0 authorization
93
68
94
69
For an API that supports OAuth 2.0 authorization, follow these steps to configure authentication settings in your API center. You can configure settings for one or both of the following OAuth 2.0 authorization flows:
95
70
96
-
***Authorization code flow with PKCE (Proof Key for Code Exchange)** - This flow is recommended for authenticating users in mobile and web applications such as the API Center portal.
97
-
***Client credentials flow** - This flow is recommended for machine-to-machine applications that don't require a specific user's permissions to access data, such as background services or daemons.
71
+
***Authorization code flow with PKCE (Proof Key for Code Exchange)** - This flow is recommended for authenticating users in the browser, such as in the API Center portal.
72
+
***Client credentials flow** - This flow is recommended for applications that don't require a specific user's permissions to access data.
98
73
99
74
100
75
### 1. Create an OAuth 2.0 app
101
76
102
-
For OAuth 2.0 authorization, create an app registration in an identity provider, such as the Microsoft Entra tenant associated with your Azure subscription. The exact steps depend on the identity provider you use.
77
+
For OAuth 2.0 authorization, create an app registration in an identity provider, such as the Microsoft Entra tenant associated with your Azure subscription. The exact creation steps depend on the identity provider you use.
103
78
104
79
The following example shows how to create an app registration in Microsoft Entra ID.
105
80
106
-
107
81
1. Sign in to the [Azure portal](https://portal.azure.com) with an account with sufficient permissions in the tenant.
108
82
1. Navigate to **Microsoft Entra ID** > **+ New registration**.
109
83
1. In the **Register an application** page, enter your application registration settings:
110
84
1. In **Name**, enter a meaningful name for the app.
111
85
1. In **Supported account types**, select an option that suits your scenario, for example, **Accounts in this organizational directory only (Single tenant)**.
86
+
1. (For authorization code flow) In **Redirect URI**, select **Single-page application (SPA)** and set the URI. Enter the URI of your API Center portal deployment, in the following form: `https://<service-name>.portal.<location>.azure-api-center.ms.` Replace `<service name>` and `<location>` with the name of your API center and the location where it's deployed, Example: `https://myapicenter.portal.eastus.azure-api-center.ms`
112
87
1. Select **Register**.
113
88
1. In the left menu, under **Manage**, select **Certificates & secrets**, and then select **+ New client secret**.
114
89
1. Enter a **Description**.
@@ -125,45 +100,59 @@ In the following section, you will need the following values from the app regist
125
100
***OAuth 2.0 token endpoint (v2)** - the token URL endpoint for Microsoft Entra ID
126
101
* Any API scopes configured in the app registration.
127
102
128
-
### 2. Add OAuth 2.0 authorization in your API center
103
+
### 2. Store client secret in Azure Key Vault
104
+
105
+
To manage the secret securely, store it in Azure Key Vault, and access the key vault using your API center's managed identity.
### 3. Add OAuth 2.0 authorization in your API center
129
110
130
111
1. In the [portal](https://azure.microsoft.com), navigate to your API center.
131
112
1. In the left menu, under **Assets**, select **Authorization (preview)** > **+ Add configuration**.
132
-
1. In the **Add authorization** page, set the values as follows:
133
-
1. Enter a **Title** (name) and optional **Description** for the authorization.
134
-
1. In **Security scheme**, select **OAuth2**.
135
-
1. In **Client ID**, enter the client ID of the app that you created in the previous section.
136
-
1. In **Client secret**, enter the client secret of the app that you created in the previous section.
137
-
1. In **Authorization URL**, enter the OAuth 2.0 authorization endpoint for the identity provider.
138
-
1. In **Token URL**, enter the OAuth 2.0 token endpoint for the identity provider.
139
-
1. In **OAuth2 flow**, select one or both of the OAuth 2.0 flows that you want to use. Available values are **Authorization code (PKCE)** and **Client credentials**.
140
-
1. In **Scopes**, optionally enter one or more API scopes that your API supports, separated by " ". Example: `User.Read`
141
-
1. Select **Create**.
113
+
1. In the **Add configuration** page, set the values as follows:
|**Title**| A name and optional description for the authorization. |
118
+
|**Description**| Opitonal description for the authorization. |
119
+
|**Security scheme**| Select **OAuth2**. |
120
+
|**Client ID**| Client ID of the app that you created in the previous section. |
121
+
|**Client secret**| Enter the . |
122
+
|**Authorization URL**| OAuth 2.0 authorization endpoint for the identity provider. |
123
+
|**Token URL**| OAuth 2.0 token endpoint for the identity provider. |
124
+
|**Refresh URL**| OAuth 2.0 refresh token endpoint for the identity provider. For most providers, same as the Token URL. |
125
+
|**OAuth2 flow**| One or both of the OAuth 2.0 flows that you want to use. Available values are **Authorization code (PKCE)** and **Client credentials**. |
126
+
|**Scopes**| One or more API scopes configured for your API, separated by spaces. If no scopes are configured, enter `.default`. |
127
+
128
+
1. Select **Create** to save the configuration. |
142
129
143
130
## Add authentication configuration to an API version
144
131
145
-
After configuring settings for an API key or an OAuth 2.0 flow, add the API key or OAuth 2.0 configuration to an API version in your inventory.
132
+
After configuring settings for an API key or an OAuth 2.0 flow, add the API key or OAuth 2.0 configuration to an API version in your API center.
146
133
147
134
1. In the [portal](https://azure.microsoft.com), navigate to your API center.
148
135
1. In the left menu, under **Assets**, select **APIs**.
149
-
1. Select an API that you want to associate the authorization with.
136
+
1. Select an API that you want to associate the authorization configuration with.
150
137
1. In the left menu, under **Details**, select **Versions**.
151
138
1. Select the API version that you want to add the authentication configuration to.
152
139
1. In the left menu, under **Details**, select **Manage Access (preview)** > **+ Add authentication**.
153
-
1. In the **Add authentication** page, select an available **Authentication configuration** that you want to associate with the API version.
140
+
1. In the **Add authentication** page, select an available **Authentication configuration** that you want to associate.
154
141
1. Select **Create**.
155
142
156
143
> [!NOTE]
157
-
> You can add multiple authentication configurations to an API version. For example, you can add both API key and OAuth 2.0 configurations to the same API version. Similarly, you can add the same configurations to multiple API versions.
144
+
> You can add multiple authentication configurations to an API version. For example, you can add both API key and OAuth 2.0 configurations to the same API version, if supported by the API. Similarly, you can add the same configurations to multiple API versions.
158
145
159
146
## Manage access by specific users or groups
160
147
161
-
You can manage access to an API version's authentication configuration by specific users or groups in your organization. You do this by configuring an access policy that assigns users or groups the **API Center Credential Access Reader** role, scoped to specific authentication configurations in the API version. This is useful, for example, if you want to allow only specific users to test an API in the API Center portal.
148
+
You can manage access by specific users or groups in your organization to an API version's authentication configuration. You do this by configuring an access policy that assigns users or groups the **API Center Credential Access Reader** role, scoped to specific authentication configurations in the API version. This is useful, for example, if you want to allow only specific users to test an API in the API Center portal using an API key or OAuth 2.0 flow.
162
149
163
150
1. In the [portal](https://azure.microsoft.com), navigate to your API center.
164
151
1. Navigate to an API version to which you've added an authentication configuration (see previous section).
165
152
1. In the left menu, under **Details**, select **Manage Access (preview)**.
166
153
1. Select the **Edit access policies** dropdown at the end of the row for the authentication configuration whose access you want to manage.
154
+
:::image type="content" source="media/authorize-api-access/edit-access-policies.png" alt-text="Screenshot of adding an access policy in the portal.":::
155
+
167
156
1. In the **Manage access** page, select **+ Add > Users** or **+ Add > Groups**.
168
157
1. Search for and select the users (or groups) that you want to add. You can select multiple items.
169
158
1. Click **Select**.
@@ -194,4 +183,5 @@ You can use the API Center portal to test an API that you configured for authent
194
183
## Related content
195
184
196
185
*[Set up API Center portal](set-up-api-center-portal.md)
197
-
*[Enable the Azure API Center portal view in Visual Studio Code](enable-api-center-portal-vs-code-extension.md)
186
+
*[Enable the Azure API Center portal view in Visual Studio Code](enable-api-center-portal-vs-code-extension.md)
187
+
*[Authentication and authorization to APIs in Azure API Management](../api-management/authentication-authorization-overview.md)
To store the API key as a secret in the key vault, see [Set and retrieve secret in Key Vault](/azure/key-vault/secrets/quick-create-portal).
16
+
17
+
> [!NOTE]
18
+
> The *secret identifier* of the secret appears on the secret's details page. This is a URI of the form `https://<key-vault-name>.vault.azure.net/secrets/<secret-name>/<version>`. You need this value when you configure the secret in your API center.
19
+
20
+
#### Enable a managed identity in your API center
21
+
22
+
For this scenario, your API center uses a [managed identity](/entra/identity/managed-identities-azure-resources/overview) to access the key vault. Depending on your needs, enable either a system-assigned or one or more user-assigned managed identities.
23
+
24
+
The following example shows how to enable a system-assigned managed identity by using the Azure portal. At a high level, configuration steps are similar for a user-assigned managed identity.
25
+
26
+
27
+
1. In the [portal](https://azure.microsoft.com), navigate to your API center.
28
+
1. In the left menu, under **Security**, select **Managed identities**.
29
+
1. Select **System assigned**, and set the status to **On**.
30
+
1. Select **Save**.
31
+
32
+
#### Assign the Key Vault Secrets User role to the managed identity
33
+
34
+
Assign your API center's managed identity the **Key Vault Secrets User** role in your key vault. The following steps use the Azure portal.
35
+
36
+
1. In the [portal](https://azure.microsoft.com), navigate to your key vault.
37
+
1. In the left menu, select **Access control (IAM)**.
38
+
1. Select **+ Add role assignment**.
39
+
1. On the **Add role assignment** page, set the values as follows:
40
+
1. On the **Role** tab, select **Key Vault Secrets User**.
41
+
1. On the **Members** tab, in **Assign access to**, select **Managed identity** > **+ Select members**.
42
+
1. On the **Select managed identities** page, select the system-assigned managed identity of your API center that you added in the previous section. Click **Select**.
0 commit comments