Skip to content

Commit 95ded86

Browse files
authored
Merge pull request #239133 from garrodonnell/post-build-updates
[CIAM] Post Build Updates to React SPA Guides
2 parents 647bad3 + bcebccf commit 95ded86

File tree

5 files changed

+31
-53
lines changed

5 files changed

+31
-53
lines changed

articles/active-directory/external-identities/customers/how-to-single-page-application-react-prepare-app.md

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
---
2-
title: Prepare a React Single Page App (SPA) for authentication
3-
description: Learn how to prepare a React single-page app (SPA) for authentication and authorization with your Azure Active Directory (AD) for customers tenant.
2+
title: Prepare a React single-page app (SPA) for authentication
3+
description: Learn how to prepare a React single-page app (SPA) for authentication with your Azure Active Directory (AD) for customers tenant.
44
services: active-directory
5-
author: godonnell
5+
author: garrodonnell
66
manager: celestedg
77
ms.service: active-directory
8-
ms.workload: identity
98
ms.subservice: ciam
109
ms.topic: how-to
1110
ms.date: 05/23/2023
1211
ms.author: godonnell
13-
ms.custom: it-pro
1412

15-
#Customer intent: As a dev, devops, or IT admin, enable authentication in my own React
13+
#Customer intent: As a dev, devops, or IT admin, I want to learn how to enable authentication in my own React single-page app
1614
---
17-
# Prepare a React Single-page application for authentication
18-
19-
After registration is complete, a React project can be created using an integrated development environment (IDE). This tutorial demonstrates how to create a React Single-page application using npm and create files needed for authentication and authorization.
15+
# Prepare a React single-page app (SPA) for authentication
16+
After registration is complete, you can create a React project using an integrated development environment (IDE). This tutorial demonstrates how to create a React single-page app using npm and create files needed for authentication and authorization.
2017

2118
In this article, you learn how to:
2219

@@ -27,13 +24,12 @@ In this article, you learn how to:
2724
> * Add authentication code to the application
2825
2926
## Prerequisites
30-
* Completion of the prerequisites and steps in [Prepare your customer tenant for building a React Single Page App (SPA)](./how-to-single-page-application-react-prepare-tenant.md))
27+
* Completion of the prerequisites and steps in [Prepare your customer tenant for building a React single-page app (SPA)](./how-to-single-page-application-react-prepare-tenant.md))
3128
* Although any IDE that supports React applications can be used, Visual Studio Code is used for this guide. This can be downloaded from the [Downloads](https://visualstudio.microsoft.com/downloads/) page.
3229
* [Node.js](https://nodejs.org/en/download/)
3330

3431
## Create a new React project
35-
36-
Use the following tabs to create a React project within the IDE.
32+
Use the following tabs to create a React project within Visual Studio Code.
3733

3834
1. Open Visual Studio Code, select **File** > **Open Folder...**. Navigate to and select the location in which to create your project.
3935
1. Open a new terminal by selecting **Terminal** > **New Terminal**.
@@ -46,7 +42,6 @@ Use the following tabs to create a React project within the IDE.
4642
```
4743
4844
## Install identity and bootstrap packages
49-
5045
Identity related **npm** packages must be installed in the project to enable user authentication. For project styling, **Bootstrap** will be used.
5146
5247
1. In the **Terminal** bar, select the **+** icon to create a new terminal. A separate terminal window will open with the previous node terminal continuing to run in the background.
@@ -58,7 +53,6 @@ Identity related **npm** packages must be installed in the project to enable use
5853
```
5954
6055
## Creating the authentication configuration file
61-
6256
1. In the *src* folder, create a new file called *authConfig.js*.
6357
1. Open *authConfig.js* and add the following code snippet:
6458
@@ -135,7 +129,6 @@ Identity related **npm** packages must be installed in the project to enable use
135129
136130
137131
## Modify index.js to include the authentication provider
138-
139132
All parts of the app that require authentication must be wrapped in the [`MsalProvider`](/javascript/api/@azure/msal-react/#@azure-msal-react-msalprovider) component. You instantiate a [PublicClientApplication](/javascript/api/@azure/msal-browser/publicclientapplication) then pass it to `MsalProvider`.
140133
141134
1. In the *src* folder, open *index.js* and replace the contents of the file with the following code snippet to use the `msal` packages and bootstrap styling:
@@ -146,4 +139,4 @@ All parts of the app that require authentication must be wrapped in the [`MsalPr
146139
## Next steps
147140
148141
> [!div class="nextstepaction"]
149-
> [Add Sign-in and Sign-out functionality to your app.](./how-to-single-page-application-react-sign-in-out.md)
142+
> [Add sign-in and sign-out functionality to your app.](./how-to-single-page-application-react-sign-in-out.md)

articles/active-directory/external-identities/customers/how-to-single-page-application-react-prepare-tenant.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
---
2-
title: Prepare your tenant to use a React single-page app for authentication.
2+
title: Prepare your customer tenant to authenticate users in a React single-page app (SPA)
33
description: Learn how to configure your Azure Active Directory (AD) for customers tenant for authentication with a React single-page app (SPA).
44
services: active-directory
5-
author: godonnell
5+
author: garrodonnell
66
manager: celestedg
77
ms.service: active-directory
88
ms.workload: identity
99
ms.subservice: ciam
1010
ms.topic: how-to
1111
ms.date: 05/23/2023
1212
ms.author: godonnell
13-
ms.custom: it-pro
1413

15-
#Customer intent: As a dev I want to prepare my customer tenant for building a Single Page App with React
14+
#Customer intent: As a dev I want to prepare my customer tenant for building a single-page app (SPA) with React
1615
---
17-
# Prepare your customer tenant for building a Single Page App (SPA)
16+
# Prepare your customer tenant to authenticate users in a React single-page app (SPA)
1817

19-
Before your applications can interact with Microsoft Identity Platform they must be registered in a customer tenant that you manage and must be associated with a user flow.
18+
Before your applications can interact with Microsoft identity platform they must be registered in a customer tenant that you manage and must be associated with a user flow.
2019

2120
In this article, you learn how to:
2221

2322
> [!div class="checklist"]
24-
> * Register your application and record identifiers.
25-
> * Create a user flow to allow sign-up and sign-in.
26-
> * Associate the user flow with your application.
23+
> * Register your application and record identifiers
24+
> * Create a user flow to allow sign-up and sign-in
25+
> * Associate the user flow with your application
2726
2827
## Prerequisites
2928

@@ -54,4 +53,4 @@ If you haven't already created your own customer tenant, [create one now](https:
5453
## Next steps
5554

5655
> [!div class="nextstepaction"]
57-
> [Start building your React Single Page Application](./how-to-single-page-application-react-prepare-app.md)
56+
> [Start building your React single-page app](./how-to-single-page-application-react-prepare-app.md)

articles/active-directory/external-identities/customers/how-to-single-page-application-react-sample.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
11
---
22
title: Sign in users in a sample React single-page application
3-
description: Learn how to configure a sample React SPA to sign in and sign out users.
3+
description: Learn how to configure a sample React single-page app (SPA) to sign in and sign out users.
44
services: active-directory
55
author: garrodonnell
66
manager: celestedg
77
ms.author: godonnell
88
ms.service: active-directory
9-
ms.workload: identity
109
ms.subservice: ciam
1110
ms.topic: how-to
1211
ms.date: 05/23/2023
13-
ms.custom: developer
1412

15-
#Customer intent: As a dev, devops, I want to learn about how to configure a sample React Single Page Application to sign in and sign out users with my Azure Active Directory (Azure AD) for customers tenant
13+
#Customer intent: As a dev, devops, I want to learn about how to configure a sample React single-page app to sign in and sign out users with my Azure Active Directory (Azure AD) for customers tenant
1614
---
1715

18-
# Sign in users in a sample React single-page application
16+
# Sign in users in a sample React single-page app (SPA)
1917

2018
This how-to guide uses a sample React single-page application (SPA) to demonstrate how to add authentication to a SPA. This SPA enables users to sign in and sign out by using you Azure Active Directory (Azure AD) for customers tenant. The sample uses the [Microsoft Authentication Library for JavaScript (MSAL.js)](https://github.com/AzureAD/microsoft-authentication-library-for-js) to handle authentication.
2119

2220
## Prerequisites
23-
24-
* Although any IDE that supports vanilla JS applications can be used, **Visual Studio Code** is used for this guide. It can be downloaded from the [Downloads](https://visualstudio.microsoft.com/downloads) page.
21+
* Although any IDE that supports React applications can be used, **Visual Studio Code** is used for this guide. It can be downloaded from the [Downloads](https://visualstudio.microsoft.com/downloads) page.
2522
* [Node.js](https://nodejs.org/en/download/).
2623
* Azure AD for customers tenant. If you don't already have one, [sign up for a free trial](https://aka.ms/ciam-free-trial?wt.mc_id=ciamcustomertenantfreetrial_linkclick_content_cnl).
2724

@@ -98,5 +95,5 @@ All the required code snippets have been added, so the application can now be ca
9895
1. Once signed in the display name is shown next to the **Sign out** button.
9996
10097
## Next steps
101-
102-
Learn how to use the Microsoft Authentication Library (MSAL) for JavaScript to sign in users and acquire tokens to call Microsoft Graph.
98+
> [!div class="nextstepaction"]
99+
> [Enable self-service password reset](./how-to-enable-password-reset-customers.md)

articles/active-directory/external-identities/customers/how-to-single-page-application-react-sign-in-out.md

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Sign in users with a React single-page-application
2+
title: Add sign-in to a React single-page app (SPA)
33
description: Learn how to configure a React single-page app (SPA) to sign in and sign out users with your Azure Active Directory (AD) for customers tenant.
44
services: active-directory
55
author: godonnell
@@ -12,11 +12,10 @@ ms.date: 05/23/2023
1212
ms.author: godonnell
1313
ms.custom: it-pro
1414

15-
#Customer intent: As a developer I want to add sign-in and sign-out functionality to my React Single Page App
15+
#Customer intent: As a developer I want to add sign-in and sign-out functionality to my React single-page app
1616
---
1717

18-
# Create components for sign in and sign out in a React single page app
19-
18+
# Add sign-in to a React single-page app (SPA)
2019
Functional components are the building blocks of React apps. This tutorial demonstrates how functional components can be used to build the sign in and sign out experience in a React single-page app (SPA). The `useMsal` hook is used to retrieve an access token to allow user sign in.
2120

2221
In this tutorial:
@@ -30,7 +29,7 @@ In this tutorial:
3029
3130
## Prerequisites
3231

33-
* Completion of the prerequisites and steps in [Prepare an Single Page Application for authentication](how-to-single-page-application-react-prepare-app.md).
32+
* Completion of the prerequisites and steps in [Prepare an single-page app for authentication](how-to-single-page-application-react-prepare-app.md).
3433

3534

3635
## Adding components to the application
@@ -42,8 +41,6 @@ In this tutorial:
4241
- *SignInButton.jsx*
4342
- *SignOutButton.jsx*
4443

45-
---
46-
4744
Once complete, you should have the following folder structure.
4845

4946
```txt
@@ -58,7 +55,6 @@ reactspalocal/
5855
```
5956

6057
### Adding the page layout
61-
6258
1. Open *PageLayout.jsx* and add the following code to render the page layout. The [useIsAuthenticated](/javascript/api/@azure/msal-react) hook returns whether or not a user is currently signed-in.
6359

6460
```javascript
@@ -110,7 +106,6 @@ reactspalocal/
110106
1. Save the file.
111107

112108
### Adding the sign in experience
113-
114109
1. Open *SignInButton.jsx* and add the following code, which creates a button that signs in the user using either a pop-up or redirect.
115110

116111
```javascript
@@ -163,7 +158,6 @@ reactspalocal/
163158
1. Save the file.
164159

165160
### Adding the sign out experience
166-
167161
1. Open *SignOutButton.jsx* and add the following code, which creates a button that signs out the user using either a pop-up or redirect.
168162

169163
```javascript
@@ -210,7 +204,6 @@ reactspalocal/
210204
```
211205

212206
## Change filename and add required imports
213-
214207
By default, the application runs via a JavaScript file called *App.js*. It needs to be renamed to *App.jsx*, which is an extension that allows a developer to write HTML in React.
215208

216209
1. Rename App.js to App.jsx.
@@ -230,7 +223,6 @@ By default, the application runs via a JavaScript file called *App.js*. It needs
230223
```
231224

232225
### Replacing the default function to render authenticated information
233-
234226
The following code will render based on whether the user is authenticated or not. Replace the default function `App()` to render authenticated information with the following code:
235227

236228
```javascript
@@ -267,7 +259,6 @@ export default function App() {
267259
```
268260

269261
## Run your project and sign in
270-
271262
All the required code snippets have been added, so the application can now be called and tested in a web browser.
272263

273264
1. Open a new terminal by selecting **Terminal** > **New Terminal**.
@@ -277,20 +268,18 @@ All the required code snippets have been added, so the application can now be ca
277268
npm start
278269
```
279270
280-
1. Open a web browser and navigate to the port specified in [Prepare a Single-page application for authentication](./how-to-single-page-application-react-prepare-app.md). For example, http://localhost:3000/.
271+
1. Open a web browser and navigate to the port specified in [Prepare a single-page application for authentication](./how-to-single-page-application-react-prepare-app.md). For example, http://localhost:3000/.
281272
1. For the purposes of this how-to, choose the **Sign in using Popup** option.
282273
1. After the popup window appears with the sign-in options, select the account with which to sign-in.
283274
1. A second window may appear indicating that a code will be sent to your email address. If this happens, select **Send code**. Open the email from the sender Microsoft account team, and enter the 7-digit single-use code. Once entered, select **Sign in**.
284275
1. For **Stay signed in**, you can select either **No** or **Yes**.
285276
1. The app will now ask for permission to sign-in and access data. Select **Accept** to continue.
286277
287278
## Sign out of the application
288-
289279
1. To sign out of the application, select **Sign out** in the navigation bar.
290280
1. A window appears asking which account to sign out of.
291281
1. Upon successful sign out, a final window appears advising you to close all browser windows.
292282
293283
## Next steps
294-
295284
> [!div class="nextstepaction"]
296285
> [Enable self-service password reset](./how-to-enable-password-reset-customers.md)

articles/active-directory/external-identities/customers/toc.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ items:
111111
- name: Prepare app
112112
href: how-to-single-page-application-react-prepare-app.md
113113
- name: Sign in and sign out
114-
href: how-to-single-page-application-react-prepare-app.md
114+
href: how-to-single-page-application-react-sign-in-out.md
115115
- name: Web app
116116
items:
117117
- name: Node/Express.js
@@ -266,7 +266,7 @@ items:
266266
href: microsoft-graph-operations-user-flow.md
267267
- name: Company branding operations
268268
href: microsoft-graph-operations-branding.md
269-
- name: Customer extensions
269+
- name: Custom extensions
270270
href: microsoft-graph-operations-custom-extensions.md
271271
- name: Tenant management operations
272272
href: azure-rest-api-operations-tenant-management.md

0 commit comments

Comments
 (0)