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/access-tokens.md
+17-18Lines changed: 17 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
---
2
-
title: Request an access token - Azure Active Directory B2C
2
+
title: Request an access token in Azure Active Directory B2C
3
3
description: Learn how to request an access token from Azure Active Directory B2C.
4
4
services: active-directory-b2c
5
5
author: kengaderdus
@@ -8,20 +8,20 @@ manager: CelesteDG
8
8
ms.service: active-directory
9
9
ms.workload: identity
10
10
ms.topic: conceptual
11
-
ms.date: 02/07/2022
11
+
ms.date: 03/09/2023
12
12
ms.custom: project-no-code
13
13
ms.author: kengaderdus
14
14
ms.subservice: B2C
15
15
16
16
---
17
17
# Request an access token in Azure Active Directory B2C
18
18
19
-
An *access token* contains claims that you can use in Azure Active Directory B2C (Azure AD B2C) to identify the granted permissions to your APIs. When calling a resource server, an access token must be present in the HTTP request. An access token is denoted as **access_token** in the responses from Azure AD B2C.
19
+
An *access token* contains claims that you can use in Azure Active Directory B2C (Azure AD B2C) to identify the granted permissions to your APIs. To call a resource server, the HTTP request must include an access token. An access token is denoted as **access_token** in the responses from Azure AD B2C.
20
20
21
21
This article shows you how to request an access token for a web application and web API. For more information about tokens in Azure AD B2C, see the [overview of tokens in Azure Active Directory B2C](tokens-overview.md).
22
22
23
23
> [!NOTE]
24
-
> **Web API chains (On-Behalf-Of) is not supported by Azure AD B2C.** - Many architectures include a web API that needs to call another downstream web API, both secured by Azure AD B2C. This scenario is common in clients that have a web API back end, which in turn calls a another service. This chained web API scenario can be supported by using the OAuth 2.0 JWT Bearer Credential grant, otherwise known as the On-Behalf-Of flow. However, the On-Behalf-Of flow is not currently implemented in Azure AD B2C. Although On-Behalf-Of works for applications registered in Azure AD, it does not work for applications registered in Azure AD B2C, regardless of the tenant (Azure AD or Azure AD B2C) that is issuing the tokens.
24
+
> **Web API chains (On-Behalf-Of) is not supported by Azure AD B2C** - Many architectures include a web API that needs to call another downstream web API, both secured by Azure AD B2C. This scenario is common in clients that have a web API back end, which in turn calls a another service. This chained web API scenario can be supported by using the OAuth 2.0 JWT Bearer Credential grant, otherwise known as the On-Behalf-Of flow. However, the On-Behalf-Of flow is not currently implemented in Azure AD B2C. Although On-Behalf-Of works for applications registered in Azure AD, it does not work for applications registered in Azure AD B2C, regardless of the tenant (Azure AD or Azure AD B2C) that is issuing the tokens.
25
25
26
26
## Prerequisites
27
27
@@ -60,17 +60,7 @@ If the **response_type** parameter in an `/authorize` request includes `token`,
60
60
61
61
## Request a token
62
62
63
-
To request an access token, you need an authorization code. Below is an example of a request to the `/authorize` endpoint for an authorization code.
64
-
65
-
In the following example, you replace these values in the query string:
66
-
67
-
-`<tenant-name>` - The name of your [Azure AD B2C tenant](tenant-management-read-tenant-name.md#get-your-tenant-name). If you're using a custom domain, replace `tenant-name.b2clogin.com` with your domain, such as `contoso.com`.
68
-
-`<policy-name>` - The name of your custom policy or user flow.
69
-
-`<application-ID>` - The application identifier of the web application that you registered to support the user flow.
70
-
-`<application-ID-URI>` - The application identifier URI that you set under **Expose an API** blade of the client application.
71
-
-`<scope-name>` - The name of the scope that you added under **Expose an API** blade of the client application.
72
-
-`<redirect-uri>` - The **Redirect URI** that you entered when you registered the client application.
73
-
63
+
To request an access token, you need an authorization code. The following is an example of a request to the `/authorize` endpoint for an authorization code:
74
64
```http
75
65
GET https://<tenant-name>.b2clogin.com/<tenant-name>.onmicrosoft.com/<policy-name>/oauth2/v2.0/authorize?
76
66
client_id=<application-ID>
@@ -80,17 +70,26 @@ client_id=<application-ID>
80
70
&response_type=code
81
71
```
82
72
73
+
Replace the values in the query string as follows:
74
+
75
+
-`<tenant-name>` - The name of your [Azure AD B2C tenant](tenant-management-read-tenant-name.md#get-your-tenant-name). If you're using a custom domain, replace `tenant-name.b2clogin.com` with your domain, such as `contoso.com`.
76
+
-`<policy-name>` - The name of your custom policy or user flow.
77
+
-`<application-ID>` - The application identifier of the web application that you registered to support the user flow.
78
+
-`<application-ID-URI>` - The application identifier URI that you set under **Expose an API** blade of the client application.
79
+
-`<scope-name>` - The name of the scope that you added under **Expose an API** blade of the client application.
80
+
-`<redirect-uri>` - The **Redirect URI** that you entered when you registered the client application.
81
+
83
82
To get a feel of how the request works, paste the request into your browser and run it.
84
83
85
-
This is the interactive part of the flow, where you take action. You're asked to complete the user flow's workflow. This might involve entering your username and password in a sign in form or any other number of steps. The steps you complete depend on how the user flow is defined.
84
+
This's the interactive part of the flow, where you take action. You're asked to complete the user flow's workflow. This might involve entering your username and password in a sign in form or any other number of steps. The steps you complete depend on how the user flow is defined.
86
85
87
86
The response with the authorization code should be similar to this example:
After successfully receiving the authorization code, you can use it to request an access token. Note that the parameters are in the body of the HTTP POST request:
92
+
After successfully receiving the authorization code, you can use it to request an access token. The parameters are in the body of the HTTP POST request:
94
93
95
94
```http
96
95
POST <tenant-name>.b2clogin.com/<tenant-name>.onmicrosoft.com/<policy-name>/oauth2/v2.0/token HTTP/1.1
@@ -105,7 +104,7 @@ grant_type=authorization_code
105
104
&client_secret=2hMG2-_:y12n10vwH...
106
105
```
107
106
108
-
If you're testing this POST HTTP request, you can use any HTTP client such as [Microsoft PowerShell](/powershell/scripting/overview) or [Postman](https://www.postman.com/).
107
+
If you want to test this POST HTTP request, you can use any HTTP client such as [Microsoft PowerShell](/powershell/scripting/overview) or [Postman](https://www.postman.com/).
Copy file name to clipboardExpand all lines: articles/active-directory-b2c/configure-authentication-sample-angular-spa-app.md
+10-9Lines changed: 10 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ manager: CelesteDG
7
7
ms.service: active-directory
8
8
ms.workload: identity
9
9
ms.topic: how-to
10
-
ms.date: 03/30/2022
10
+
ms.date: 03/09/2023
11
11
ms.author: kengaderdus
12
12
ms.subservice: B2C
13
13
ms.custom: "b2c-support"
@@ -35,7 +35,7 @@ The sign-in flow involves the following steps:
35
35
36
36
### App registration
37
37
38
-
To enable your app to sign in with Azure AD B2C and call a web API, you must register two applications in the Azure AD B2C directory:
38
+
To enable your app to sign in with Azure AD B2C and call a web API, you must register two applications in your Azure AD B2C tenant:
39
39
40
40
- The *single-page application* (Angular) registration enables your app to sign in with Azure AD B2C. During app registration, you specify the *redirect URI*. The redirect URI is the endpoint to which the user is redirected after they authenticate with Azure AD B2C. The app registration process generates an *application ID*, also known as the *client ID*, that uniquely identifies your app. This article uses the example **App ID: 1**.
41
41
@@ -57,7 +57,7 @@ The following diagram describes the app registrations and the app architecture.
57
57
58
58
Before you follow the procedures in this article, make sure that your computer is running:
59
59
60
-
*[Visual Studio Code](https://code.visualstudio.com/) or another code editor.
60
+
*[Visual Studio Code](https://code.visualstudio.com/) or any other code editor.
61
61
*[Node.js runtime](https://nodejs.org/en/download/) and [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm).
62
62
*[Angular CLI](https://angular.io/cli).
63
63
@@ -82,8 +82,9 @@ In this step, you create the registrations for the Angular SPA and the web API a
82
82
Follow these steps to create the Angular app registration:
83
83
84
84
1. Sign in to the [Azure portal](https://portal.azure.com).
85
-
1. Make sure you're using the directory that contains your Azure AD B2C tenant. Select the **Directories + subscriptions** icon in the portal toolbar.
86
-
1. On the **Portal settings | Directories + subscriptions** page, find your Azure AD B2C directory in the **Directory name** list, and then select **Switch**.
85
+
1. Make sure you're using the directory that contains your Azure AD B2C tenant:
86
+
1. Select the **Directories + subscriptions** icon in the portal toolbar.
87
+
2. On the **Portal settings | Directories + subscriptions** page, find your Azure AD B2C directory in the **Directory name** list, and then select **Switch**.
87
88
1. In the Azure portal, search for and select **Azure AD B2C**.
88
89
1. Select **App registrations**, and then select **New registration**.
89
90
1. For **Name**, enter a name for the application. For example, enter **MyApp**.
@@ -203,7 +204,7 @@ Your final configuration file should look like the following JSON:
203
204
204
205
## Step 5: Run the Angular SPA and web API
205
206
206
-
You're now ready to test the Angular scoped access to the API. In this step, run both the web API and the sample Angular application on your local machine. Then, log in to the Angular application, and select the **TodoList** button to start a request to the protected API.
207
+
You're now ready to test the Angular scoped access to the API. In this step, run both the web API and the sample Angular application on your local machine. Then, sign in to the Angular application, and select the **TodoList** button to start a request to the protected API.
207
208
208
209
### Run the web API
209
210
@@ -252,8 +253,8 @@ You're now ready to test the Angular scoped access to the API. In this step, run
252
253
253
254

254
255
255
-
1. Complete the sign-up or login process.
256
-
1. Upon successful login, you should see your profile. From the menu, select **TodoList**.
256
+
1. Complete the sign-up or sign-in process.
257
+
1. Upon successful sign-in, you should see your profile. From the menu, select **TodoList**.
257
258
258
259

259
260
@@ -275,4 +276,4 @@ You can add and modify redirect URIs in your registered applications at any time
275
276
* [Learn more about the code sample](https://github.com/Azure-Samples/ms-identity-javascript-angular-tutorial/)
276
277
* [Enable authentication in your own Angular application](enable-authentication-angular-spa-app.md)
277
278
* [Configure authentication options in your Angular application](enable-authentication-angular-spa-app-options.md)
278
-
* [Enable authentication in your own web API](enable-authentication-web-api.md)
279
+
* [Enable authentication in your own web API](enable-authentication-web-api.md)
0 commit comments