Skip to content

Commit 362a587

Browse files
committed
add-out-of-repo-snippet
1 parent 7fbc1df commit 362a587

File tree

1 file changed

+3
-74
lines changed

1 file changed

+3
-74
lines changed

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

Lines changed: 3 additions & 74 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
@@ -57,85 +57,14 @@ To obtain the sample application, you can either clone it from GitHub or downloa
5757
```console
5858
git clone https://github.com/Azure-Samples/ms-identity-javascript-tutorial
5959
```
60-
61-
- [Download the .zip file](https://github.com/Azure-Samples/ms-identity-javascript-tutorial/archive/refs/heads/main.zip).
60+
- [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.
6261

6362
## Configure the project
6463

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

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-
```
67+
:::code language="csharp" source="~/ms-identity-docs-code-javascript/js-spa/App/authConfig.js":::
13968

14069
* `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.
14170
* `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.

0 commit comments

Comments
 (0)