Skip to content

Commit 52a3149

Browse files
committed
sync with updated sample
1 parent ea547fa commit 52a3149

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

articles/active-directory-b2c/tutorial-single-page-app-webapi.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ git clone https://github.com/Azure-Samples/active-directory-b2c-javascript-nodej
7676
```javascript
7777
var clientID = "<your-webapi-application-ID>"; // Application (client) ID
7878
var b2cDomainHost = "<your-tenant-name>.b2clogin.com";
79-
var tenantId = "<your-tenant-ID>.onmicrosoft.com";
79+
var tenantId = "<your-tenant-ID>.onmicrosoft.com"; // Alternatively, you can use your Directory (tenant) ID (a GUID)
8080
var policyName = "B2C_1_signupsignin1";
8181
```
8282

8383
#### Enable CORS
8484

8585
To allow your single-page application to call the Node.js web API, you need to enable [CORS](https://expressjs.com/en/resources/middleware/cors.html) in the web API. In a production application you should be careful about which domain is making the request, but for this tutorial, allow requests from any domain.
8686

87-
To enable CORS, use the following middleware. In the Node.js web API code sample used in this tutorial, you can find this code in the *index.js* file.
87+
To enable CORS, use the following middleware. In the Node.js web API code sample in this tutorial, it's already been added to the *index.js* file.
8888
8989
```javascript
9090
app.use((req, res, next) => {
@@ -96,9 +96,9 @@ app.use((req, res, next) => {
9696
9797
### Configure the single-page application
9898
99-
The single-page application (SPA) from the [previous tutorial](tutorial-single-page-app.md) in the series uses Azure AD B2C for user sign-up and sign-in, and calls the Node.js web API protected by the *frabrikamb2c* demo tenant.
99+
The single-page application (SPA) from the [previous tutorial](tutorial-single-page-app.md) in the series uses Azure AD B2C for user sign-up and sign-in, and by default, calls the Node.js web API protected by the *frabrikamb2c* demo tenant.
100100
101-
In this section, you update the single-page application to call the Node.js web API protected by *your* Azure AD B2C tenant (and which you run on your local machine).
101+
In this section, you update the single-page web application to call the Node.js web API protected by *your* Azure AD B2C tenant (and which you run on your local machine).
102102
103103
To change the settings in the SPA:
104104
@@ -110,26 +110,26 @@ To change the settings in the SPA:
110110
The `apiConfig` definition should look similar to the following code block, but with your B2C tenant's name in the place of `<your-tenant-name>`:
111111

112112
```javascript
113+
// The current application coordinates were pre-registered in a B2C tenant.
113114
const apiConfig = {
114-
b2cScopes: ["https://<your-tenant-name>.onmicrosoft.com/api/demo.read"],
115-
webApi: "http://localhost:5000/"
116-
};
117-
118-
// request to acquire a token for resource access
119-
const tokenRequest = {
120-
scopes: apiConfig.b2cScopes
115+
b2cScopes: ["https://<your-tenant-name>.onmicrosoft.com/api/demo.read"],
116+
webApi: "http://localhost:5000/"
121117
};
122118
```
123119

124120
## Run the SPA and web API
125121

126-
Finally, you run both the Node.js web API and the sample JavaScript single-page application on your local machine. Then, you sign in to the single-page application and press a button to initiate a request to the protected API.
122+
You're now ready to test the single-page application's scoped access to the API. Run both the Node.js web API and the sample JavaScript single-page application on your local machine. Then, sign in to the single-page application and select the **Call API** button to initiate a request to the protected API.
127123

128-
Although both applications run locally in this tutorial, they use Azure AD B2C for secure sign-up/sign-in and to grant access to the protected web API.
124+
Although both applications are running locally when you follow this tutorial, you've configured them to use Azure AD B2C for secure sign-up/sign-in and to grant access to the protected web API.
129125
130126
### Run the Node.js web API
131127
132-
1. Open a console window and change to the directory containing the Node.js web API sample. For example: `cd active-directory-b2c-javascript-nodejs-webapi`
128+
1. Open a console window and change to the directory containing the Node.js web API sample. For example:
129+
130+
```console
131+
cd active-directory-b2c-javascript-nodejs-webapi
132+
```
133133
134134
1. Run the following commands:
135135
@@ -146,7 +146,7 @@ Although both applications run locally in this tutorial, they use Azure AD B2C f
146146
147147
### Run the single-page app
148148
149-
1. Open a console window and change to the directory containing the JavaScript SPA sample. For example:
149+
1. Open another console window and change to the directory containing the JavaScript SPA sample. For example:
150150
151151
```console
152152
cd active-directory-b2c-javascript-msal-singlepageapp

0 commit comments

Comments
 (0)