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: README.md
+7-10Lines changed: 7 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -27,15 +27,15 @@ description: "This sample demonstrates a JavaScript SPA application calling a No
27
27
28
28
## Overview
29
29
30
-
This sample demonstrates [how to protect a Node.js Web API](https://docs.microsoft.com/azure/active-directory/develop/quickstart-configure-app-expose-web-apis) with [Microsoft identity platform](https://docs.microsoft.com/azure/active-directory/develop/) and [Azure Active Directory (Azure AD)](https://docs.microsoft.com/azure/active-directory/fundamentals/active-directory-whatis) using the [passport-azure-ad](https://github.com/AzureAD/passport-azure-ad) library.
30
+
This sample demonstrates [how to protect a Node.js Web API](https://docs.microsoft.com/azure/active-directory/develop/quickstart-configure-app-expose-web-apis) with [Microsoft identity platform](https://docs.microsoft.com/azure/active-directory/develop/) and [Azure AD B2C](https://docs.microsoft.com/azure/active-directory-b2c/overview) using the [passport-azure-ad](https://github.com/AzureAD/passport-azure-ad) library.
31
31
32
32
You will need a **client** application for calling the Web API. Choose:
33
33
34
34
-[JavaScript Single-page Application calling a custom Web API with MSAL.js 2.x using the auth code flow with PKCE](https://github.com/Azure-Samples/ms-identity-b2c-javascript-spa).
35
35
36
36
## Scenario
37
37
38
-
1. The client application uses the [Microsoft Authentication Library for JavaScript (MSAL.js)](https://github.com/AzureAD/microsoft-authentication-library-for-js) to sign-in a user and obtain a JWT [Access Token](https://docs.microsoft.com/azure/active-directory/develop/access-tokens) from **Azure AD**.
38
+
1. The client application uses the [Microsoft Authentication Library for JavaScript (MSAL.js)](https://github.com/AzureAD/microsoft-authentication-library-for-js) to sign-in a user and obtain a JWT [Access Token](https://docs.microsoft.com/azure/active-directory/develop/access-tokens) from **Azure AD B2C**.
39
39
1. The **Access Token** is used as a *bearer* token to authenticate the user when calling this web API.
40
40
1. The web API responds with the name of the user obtained from the token claims.
41
41
@@ -108,18 +108,15 @@ Please refer to: [Tutorial: Add identity providers to your applications in Azure
108
108
1. Select **Register** to create the application.
109
109
1. In the app's registration screen, find and note the **Application (client) ID**. You use this value in your app's configuration file(s) later in your code.
110
110
1. Select **Save** to save your changes.
111
-
1. In the app's registration screen, select the **Expose an API** blade to the left to open the page where you can declare the parameters to expose this app as an Api for which client applications can obtain [access tokens](https://docs.microsoft.com/azure/active-directory/develop/access-tokens) for.
112
-
The first thing that we need to do is to declare the unique [resource](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-auth-code-flow) URI that the clients will be using to obtain access tokens for this Api. To declare an resource URI, follow the following steps:
111
+
1. In the app's registration screen, select the **Expose an API** blade to the left to open the page where you can declare the parameters to expose this app as an API for which client applications can obtain [access tokens](https://docs.microsoft.com/azure/active-directory/develop/access-tokens) for.
112
+
The first thing that we need to do is to declare the unique [resource](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-auth-code-flow) URI that the clients will be using to obtain access tokens for this API. To declare an resource URI, follow the following steps:
113
113
- Click `Set` next to the **Application ID URI** to generate a URI that is unique for this app.
114
114
- For this sample, accept the proposed Application ID URI (api://{clientId}) by selecting **Save**.
115
-
1. All Apis have to publish a minimum of one [scope](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-auth-code-flow#request-an-authorization-code) for the client's to obtain an access token successfully. To publish a scope, follow the following steps:
115
+
1. All APIs have to publish a minimum of one [scope](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-auth-code-flow#request-an-authorization-code) for the client's to obtain an access token successfully. To publish a scope, follow the following steps:
116
116
- Select **Add a scope** button open the **Add a scope** screen and Enter the values as indicated below:
117
117
- For **Scope name**, use `demo.read`.
118
-
- Select **Admins and users** options for **Who can consent?**
119
118
- For **Admin consent display name** type `Access active-directory-b2c-javascript-nodejs-webapi`
120
119
- For **Admin consent description** type `Allows the app to access active-directory-b2c-javascript-nodejs-webapi as the signed-in user.`
121
-
- For **User consent display name** type `Access active-directory-b2c-javascript-nodejs-webapi`
122
-
- For **User consent description** type `Allow the application to access active-directory-b2c-javascript-nodejs-webapi on your behalf.`
123
120
- Keep **State** as **Enabled**
124
121
- Click on the **Add scope** button on the bottom to save this scope.
125
122
1. On the right side menu, select the `Manifest` blade.
@@ -133,7 +130,7 @@ Open the project in your IDE (like Visual Studio or Visual Studio Code) to confi
133
130
> In the steps below, "ClientID" is the same as "Application ID" or "AppId".
134
131
135
132
1. Open the `config.json` file.
136
-
1. Find the key `tenantName` and replace the existing value with your **Azure AD** tenant's name e.g. `fabrikamb2c`.
133
+
1. Find the key `tenantName` and replace the existing value with your **Azure AD B2C** tenant's name e.g. `fabrikamb2c`.
137
134
1. Find the key `clientID` and replace the existing value with the application ID (clientId) of the `active-directory-b2c-javascript-nodejs-webapi` application copied from the **Azure Portal**.
138
135
1. Find the key `policyName` and replace the existing value with name of the policy you've created, e.g. `B2C_1_SUSI`.
139
136
@@ -165,7 +162,7 @@ Consider taking a moment to [share your experience with us](https://forms.office
165
162
[passport-azure-ad](https://github.com/AzureAD/passport-azure-ad) validates the token against the `issuer`, `scope` and `audience` claims (defined in `BearerStrategy` constructor) using the `passport.authenticate()` API:
0 commit comments