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/active-directory-b2c/secure-api-management.md
-103Lines changed: 0 additions & 103 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,6 @@ Before you begin, make sure that you have the following resources in place:
29
29
* An [application that's registered in your tenant](tutorial-register-applications.md)
30
30
*[User flows that are created in your tenant](tutorial-create-user-flows.md)
31
31
* A [published API](../api-management/import-and-publish.md) in Azure API Management
32
-
* (Optional) A [Postman platform](https://www.postman.com/) to test secured access
33
32
34
33
## Get Azure AD B2C application ID
35
34
@@ -114,108 +113,6 @@ You're now ready to add the inbound policy in Azure API Management that validate
114
113
<on-error> <base /> </on-error>
115
114
</policies>
116
115
```
117
-
118
-
## Validate secure API access
119
-
120
-
To ensure that only authenticated callers can access your API, you can validate your Azure API Management configuration by calling the API with [Postman](https://www.postman.com/).
121
-
122
-
To call the API, you need both an access token that's issued by Azure AD B2C and an Azure API Management subscription key.
123
-
124
-
### Get an access token
125
-
126
-
You first need a token that's issued by Azure AD B2C to use in the `Authorization` header in Postman. You can get one by using the *Run now* feature of the sign-up/sign-in user flow you that you created as one of the prerequisites.
127
-
128
-
1. In the [Azure portal](https://portal.azure.com), go to your Azure AD B2C tenant.
129
-
1. Under **Policies**, select **User flows**.
130
-
1. Select an existing sign-up/sign-in user flow (for example, *B2C_1_signupsignin1*).
131
-
1. For **Application**, select *webapp1*.
132
-
1. For **Reply URL**, select `https://jwt.ms`.
133
-
1. Select **Run user flow**.
134
-
135
-

136
-
137
-
1. Complete the sign-in process. You should be redirected to `https://jwt.ms`.
138
-
1. Record the encoded token value that's displayed in your browser. You use this token value for the Authorization header in Postman.
139
-
140
-

141
-
142
-
### Get an API subscription key
143
-
144
-
A client application (in this case, Postman) that calls a published API must include a valid API Management subscription key in its HTTP requests to the API. To get a subscription key to include in your Postman HTTP request:
145
-
146
-
1. In the [Azure portal](https://portal.azure.com), go to your Azure API Management service instance.
147
-
1. Select **Subscriptions**.
148
-
1. Select the ellipsis (**...**) next to **Product: Unlimited**, and then select **Show/hide keys**.
149
-
1. Record the **Primary Key** for the product. You use this key for the `Ocp-Apim-Subscription-Key` header in your HTTP request in Postman.
150
-
151
-

152
-
153
-
### Test a secure API call
154
-
155
-
With the access token and Azure API Management subscription key recorded, you're now ready to test whether you've correctly configured secure access to the API.
156
-
157
-
1. Create a new `GET` request in [Postman](https://www.postman.com/). For the request URL, specify the speakers list endpoint of the API you published as one of the prerequisites. For example:
| `Authorization` | The encoded token value you recorded earlier, prefixed with `Bearer ` (include the space after "Bearer") |
166
-
| `Ocp-Apim-Subscription-Key` | The Azure API Management subscription key you recorded earlier. |
167
-
| | |
168
-
169
-
Your **GET** request URL and **Headers** should appear similar to those shown in the following image:
170
-
171
-

172
-
173
-
1. In Postman, select the **Send** button to execute the request. If you've configured everything correctly, you should be given a JSON response with a collection of conference speakers (shown here, truncated):
Now that you've made a successful request, test the failure case to ensure that calls to your API with an *invalid* token are rejected as expected. One way to perform the test is to add or change a few characters in the token value, and then run the same `GET` request as before.
203
-
204
-
1. Add several characters to the token value to simulate an invalid token. For example, you could add "INVALID" to the token value, as shown here:
205
-
206
-

207
-
208
-
1. Select the **Send** button to execute the request. With an invalid token, the expected result is a `401` unauthorized status code:
209
-
210
-
```json
211
-
{
212
-
"statusCode": 401,
213
-
"message": "Unauthorized. Access token is missing or invalid."
214
-
}
215
-
```
216
-
217
-
If you see a `401` status code, you've verified that only callers with a valid access token issued by Azure AD B2C can make successful requests to your Azure API Management API.
218
-
219
116
## Support multiple applications and issuers
220
117
221
118
Several applications typically interact with a single REST API. To enable your API to accept tokens intended for multiple applications, add their application IDs to the `<audiences>` element in the Azure API Management inbound policy.
0 commit comments