Skip to content

Commit 791e2a3

Browse files
committed
[Azure AD B2C] Resolve GitHub issues 97366
1 parent c5040c7 commit 791e2a3

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

articles/active-directory-b2c/configure-authentication-sample-react-spa-app.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ manager: CelesteDG
77
ms.service: active-directory
88
ms.workload: identity
99
ms.topic: how-to
10-
ms.date: 07/07/2022
10+
ms.date: 08/25/2022
1111
ms.author: kengaderdus
1212
ms.subservice: B2C
1313
ms.custom: "b2c-support"
1414
---
1515

1616
# Configure authentication in a sample React single-page application by using Azure Active Directory B2C
1717

18-
This article uses a sample React single-page application (SPA) to illustrate how to add Azure Active Directory B2C (Azure AD B2C) authentication to your React apps.
18+
This article uses a sample React single-page application (SPA) to illustrate how to add Azure Active Directory B2C (Azure AD B2C) authentication to your React apps. The React SPA also calls an API that's protected by Azure AD B2C itself.
1919

2020
## Overview
2121

@@ -121,7 +121,7 @@ Now that you've obtained the SPA sample, update the code with your Azure AD B2C
121121
| b2cPolicies | authorities | Replace `your-tenant-name` with your Azure AD B2C [tenant name](tenant-management.md#get-your-tenant-name). For example, use `contoso.onmicrosoft.com`. Then, replace the policy name with the user flow or custom policy that you created in [step 1](#step-1-configure-your-user-flow). For example: `https://<your-tenant-name>.b2clogin.com/<your-tenant-name>.onmicrosoft.com/<your-sign-in-sign-up-policy>`. |
122122
| b2cPolicies | authorityDomain|Your Azure AD B2C [tenant name](tenant-management.md#get-your-tenant-name). For example: `contoso.onmicrosoft.com`. |
123123
| Configuration | clientId | The React application ID from [step 2.3](#23-register-the-react-app). |
124-
| protectedResources| endpoint| The URL of the web API: `http://localhost:5000/api/todolist`. |
124+
| protectedResources| endpoint| The URL of the web API: `http://localhost:5000/hello`. |
125125
| protectedResources| scopes| The web API scopes that you created in [step 2.2](#22-configure-scopes). For example: `b2cScopes: ["https://<your-tenant-name>.onmicrosoft.com/tasks-api/tasks.read"]`. |
126126

127127
Your resulting *src/authConfig.js* code should look similar to the following sample:
@@ -156,7 +156,7 @@ export const msalConfig: Configuration = {
156156

157157
export const protectedResources = {
158158
todoListApi: {
159-
endpoint: "http://localhost:5000/api/todolist",
159+
endpoint: "http://localhost:5000/hello",
160160
scopes: ["https://your-tenant-namee.onmicrosoft.com/tasks-api/tasks.read"],
161161
},
162162
}
@@ -201,7 +201,7 @@ Your final configuration file should look like the following JSON:
201201

202202
## Step 5: Run the React SPA and web API
203203

204-
You're now ready to test the React scoped access to the API. In this step, run both the web API and the sample React application on your local machine. Then, sign in to the React application, and select the **TodoList** button to start a request to the protected API.
204+
You're now ready to test the React scoped access to the API. In this step, run both the web API and the sample React application on your local machine. Then, sign in to the React application, and select the **HelloAPI** button to start a request to the protected API.
205205

206206
### Run the web API
207207

@@ -251,11 +251,13 @@ You're now ready to test the React scoped access to the API. In this step, run b
251251
![Screenshot that shows the React sample app with the login link.](./media/configure-authentication-sample-react-spa-app/sample-app-sign-in.png)
252252

253253
1. Choose **Sign in using Popup**, or **Sign in using Redirect**.
254-
1. Complete the sign-up or sign in process. Upon successful sign in, you should see your profile.
255-
1. From the menu, select **Hello API**.
256-
1. Check out the result of the REST API call. The following screenshot shows the React sample REST API return value.
257-
254+
1. Complete the sign-up or sign in process. Upon successful sign in, you should see a page with three buttons, **HelloAPI**, **Edit Profile** and **Sign Out**.
258255
![Screenshot that shows the React sample app with the user profile, and the call to the A P I.](./media/configure-authentication-sample-react-spa-app/sample-app-call-api.png)
256+
1. From the menu, select **HelloAPI** button.
257+
1. Check out the result of the REST API call. The following screenshot shows the React sample REST API return value:
258+
259+
:::image type="content" source="./media/configure-authentication-sample-react-spa-app/sample-app-call-api-result.png" alt-text="Screenshot of the React sample app with the user profile, and the result of calling the web A P I.":::
260+
259261

260262
## Deploy your application
261263

89.7 KB
Loading

0 commit comments

Comments
 (0)