Skip to content

Commit a445e38

Browse files
authored
Merge pull request #252685 from OwenRichards1/js-patches
[GTD] JavaScript error patch work
2 parents b988c5d + 08694c8 commit a445e38

File tree

3 files changed

+8
-89
lines changed

3 files changed

+8
-89
lines changed

articles/active-directory/develop/quickstart-single-page-app-angular-sign-in.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ms.service: active-directory
88
ms.subservice: develop
99
ms.topic: quickstart
1010

11-
ms.date: 09/13/2023
11+
ms.date: 09/25/2023
1212
ms.author: henrymbugua
1313
ms.reviewer: j-mantu
1414
ms.custom: aaddev, "scenarios:getting-started", "languages:JavaScript", devx-track-js
@@ -19,8 +19,6 @@ ms.custom: aaddev, "scenarios:getting-started", "languages:JavaScript", devx-tra
1919

2020
This quickstart uses a sample Angular single-page app (SPA) to show you how to sign in users by using the [authorization code flow](/azure/active-directory/develop/v2-oauth2-auth-code-flow) with Proof Key for Code Exchange (PKCE) and call the Microsoft Graph API. The sample uses the [Microsoft Authentication Library for JavaScript](/javascript/api/@azure/msal-react) to handle authentication.
2121

22-
In this article you'll register a SPA in the Microsoft Entra admin center, and download a sample Angular SPA. Next, you'll run the sample application, sign in with your personal Microsoft account or a work/school account, and sign out.
23-
2422
## Prerequisites
2523

2624
* An Azure account with an active subscription. If you don't already have one, [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
@@ -56,8 +54,7 @@ To obtain the sample application, you can either clone it from GitHub or downloa
5654
```console
5755
git clone https://github.com/Azure-Samples/ms-identity-docs-code-javascript.git
5856
```
59-
60-
- [Download the .zip file](https://github.com/Azure-Samples/ms-identity-docs-code-javascript/archive/refs/heads/main.zip)
57+
- [Download the .zip file](https://github.com/Azure-Samples/ms-identity-docs-code-javascript/archive/refs/heads/main.zip). Extract it to a file path where the length of the name is fewer than 260 characters.
6158

6259
## Configure the project
6360

articles/active-directory/develop/quickstart-single-page-app-javascript-sign-in.md

Lines changed: 4 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ms.service: active-directory
99
ms.subservice: develop
1010
ms.topic: quickstart
1111
ms.workload: identity
12-
ms.date: 09/13/2023
12+
ms.date: 09/25/2023
1313
ms.author: henrymbugua
1414
ms.reviewer: OwenRichards1
1515
ms.custom: aaddev, "scenarios:getting-started", "languages:JavaScript", devx-track-js
@@ -20,8 +20,6 @@ ms.custom: aaddev, "scenarios:getting-started", "languages:JavaScript", devx-tra
2020

2121
This quickstart uses a sample JavaScript (JS) single-page app (SPA) to show you how to sign in users by using the [authorization code flow](/azure/active-directory/develop/v2-oauth2-auth-code-flow) with Proof Key for Code Exchange (PKCE) and call the Microsoft Graph API. The sample uses the [Microsoft Authentication Library for JavaScript](/javascript/api/@azure/msal-react) to handle authentication.
2222

23-
In this article you'll register a SPA in the Microsoft Entra admin center, and download a sample JS SPA. Next, you'll run the sample application, sign in with your personal Microsoft account or a work or school account, and sign out.
24-
2523
## Prerequisites
2624

2725
* An Azure account with an active subscription. If you don't already have one, [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
@@ -57,85 +55,14 @@ To obtain the sample application, you can either clone it from GitHub or downloa
5755
```console
5856
git clone https://github.com/Azure-Samples/ms-identity-javascript-tutorial
5957
```
60-
61-
- [Download the .zip file](https://github.com/Azure-Samples/ms-identity-javascript-tutorial/archive/refs/heads/main.zip).
58+
- [Download the .zip file](https://github.com/Azure-Samples/ms-identity-javascript-tutorial/archive/refs/heads/main.zip). Extract it to a file path where the length of the name is fewer than 260 characters.
6259

6360
## Configure the project
6461

6562
1. In your IDE, open the project folder, *ms-identity-javascript-tutorial/angular-spa*, containing the sample.
6663
1. Open *1-Authentication/1-sign-in/App/authConfig.js* and replace the file contents with the following snippet:
6764

68-
```javascript
69-
/**
70-
* Configuration object to be passed to MSAL instance on creation.
71-
* For a full list of MSAL.js configuration parameters, visit:
72-
* https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/configuration.md
73-
*/
74-
75-
const msalConfig = {
76-
auth: {
77-
clientId: 'Enter_the_Application_Id_Here', // This is the ONLY mandatory field that you need to supply.
78-
authority: 'https://login.microsoftonline.com/Enter_the_Tenant_Info_Here', // Defaults to "https://login.microsoftonline.com/common"
79-
redirectUri: '/', // You must register this URI on Azure Portal/App Registration. Defaults to window.location.href e.g. http://localhost:3000/
80-
navigateToLoginRequestUrl: true, // If "true", will navigate back to the original request location before processing the auth code response.
81-
},
82-
cache: {
83-
cacheLocation: 'sessionStorage', // Configures cache location. "sessionStorage" is more secure, but "localStorage" gives you SSO.
84-
storeAuthStateInCookie: false, // set this to true if you have to support IE
85-
},
86-
system: {
87-
loggerOptions: {
88-
loggerCallback: (level, message, containsPii) => {
89-
if (containsPii) {
90-
return;
91-
}
92-
switch (level) {
93-
case msal.LogLevel.Error:
94-
console.error(message);
95-
return;
96-
case msal.LogLevel.Info:
97-
console.info(message);
98-
return;
99-
case msal.LogLevel.Verbose:
100-
console.debug(message);
101-
return;
102-
case msal.LogLevel.Warning:
103-
console.warn(message);
104-
return;
105-
}
106-
},
107-
},
108-
},
109-
};
110-
111-
/**
112-
* Scopes you add here will be prompted for user consent during sign-in.
113-
* By default, MSAL.js will add OIDC scopes (openid, profile, email) to any login request.
114-
* For more information about OIDC scopes, visit:
115-
* https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-permissions-and-consent#openid-connect-scopes
116-
*/
117-
const loginRequest = {
118-
scopes: ["openid", "profile"],
119-
};
120-
121-
/**
122-
* An optional silentRequest object can be used to achieve silent SSO
123-
* between applications by providing a "login_hint" property.
124-
*/
125-
126-
// const silentRequest = {
127-
// scopes: ["openid", "profile"],
128-
// loginHint: "[email protected]"
129-
// };
130-
131-
// exporting config object for jest
132-
if (typeof exports !== 'undefined') {
133-
module.exports = {
134-
msalConfig: msalConfig,
135-
loginRequest: loginRequest,
136-
};
137-
}
138-
```
65+
:::code language="csharp" source="~/ms-identity-docs-code-javascript/js-spa/App/authConfig.js":::
13966

14067
* `TenantId` - The identifier of the tenant where the application is registered. Replace the text in quotes with the **Directory (tenant) ID** that was recorded earlier from the overview page of the registered application.
14168
* `ClientId` - The identifier of the application, also referred to as the client. Replace the text in quotes with the **Directory (tenant) ID** value that was recorded earlier from the overview page of the registered application.
@@ -151,7 +78,7 @@ Run the project with a web server by using Node.js:
15178
npm install
15279
npm start
15380
```
154-
1. Copy the https URL that appears in the terminal, for example, `https://localhost:3000`, and paste it into a browser. We recommend using a private or incognito browser session.
81+
1. Copy the `https` URL that appears in the terminal, for example, `https://localhost:3000`, and paste it into a browser. We recommend using a private or incognito browser session.
15582
1. Follow the steps and enter the necessary details to sign in with your Microsoft account. You'll be requested an email address so a one time passcode can be sent to you. Enter the code when prompted.
15683
1. The application will request permission to maintain access to data you have given it access to, and to sign you in and read your profile. Select **Accept**.
15784
1. The following screenshot appears, indicating that you have signed in to the application and have accessed your profile details from the Microsoft Graph API.

articles/active-directory/develop/quickstart-single-page-app-react-sign-in.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ms.service: active-directory
99
ms.subservice: develop
1010
ms.topic: quickstart
1111
ms.workload: identity
12-
ms.date: 09/13/2023
12+
ms.date: 09/25/2023
1313
ms.author: henrymbugua
1414
ms.reviewer: j-mantu
1515
ms.custom: aaddev, "scenarios:getting-started", "languages:JavaScript", devx-track-js
@@ -20,8 +20,6 @@ ms.custom: aaddev, "scenarios:getting-started", "languages:JavaScript", devx-tra
2020

2121
This quickstart uses a sample React single-page app (SPA) to show you how to sign in users by using the [authorization code flow](/azure/active-directory/develop/v2-oauth2-auth-code-flow) with Proof Key for Code Exchange (PKCE). The sample uses the [Microsoft Authentication Library for JavaScript](/javascript/api/@azure/msal-react) to handle authentication.
2222

23-
In this article you'll register a SPA in the Microsoft Entra admin center, and download a sample React SPA. Next, you'll run the sample application, sign in with your personal Microsoft account or a work or school account, and sign out.
24-
2523
## Prerequisites
2624

2725
* An Azure account with an active subscription. If you don't already have one, [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
@@ -36,7 +34,6 @@ In this article you'll register a SPA in the Microsoft Entra admin center, and d
3634
1. Select **New registration**.
3735
1. When the **Register an application** page appears, enter a name for your application, such as *identity-client-app*.
3836
1. Under **Supported account types**, select **Accounts in any organizational directory and personal Microsoft accounts**.
39-
1. The application's overview pane is displayed when registration is complete. Record the **Directory (tenant) ID** and the **Application (client) ID** to be used in your application source code.
4037
1. Select **Register**.
4138
1. The application's Overview pane displays upon successful registration. Record the **Application (client) ID** and **Directory (tenant) ID** to be used in your application source code.
4239

@@ -58,9 +55,7 @@ To obtain the sample application, you can either clone it from GitHub or downloa
5855
```console
5956
git clone https://github.com/Azure-Samples/ms-identity-docs-code-javascript.git
6057
```
61-
- [Download the .zip file](https://github.com/Azure-Samples/ms-identity-docs-code-javascript/tree/main)
62-
63-
If you choose to download the `.zip` file, extract the sample app file to a folder where the total length of the path is 260 or fewer characters.
58+
- [Download the .zip file](https://github.com/Azure-Samples/ms-identity-docs-code-javascript/tree/main). Extract it to a file path where the length of the name is fewer than 260 characters.
6459

6560
## Configure the project
6661

0 commit comments

Comments
 (0)