Skip to content

Commit d94cf96

Browse files
committed
integrate @hpsin review comments
1 parent ffc10bd commit d94cf96

File tree

9 files changed

+36
-11
lines changed

9 files changed

+36
-11
lines changed
76.9 KB
Loading
76.9 KB
Loading

articles/active-directory/develop/quickstart-v2-javascript-auth-code.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ This quickstart uses MSAL.js 2.0 with the authorization code flow. For a similar
119119
> - To restrict support to *personal Microsoft accounts only*, replace this value with `consumers`.
120120
> - `Enter_the_Redirect_Uri_Here` is `http://localhost:3000/`.
121121
>
122+
> The `authority` value in your *authConfig.js* should be similar to the following if you're using the main (global) Azure cloud:
123+
>
124+
> ```javascript
125+
> authority: "https://login.microsoftonline.com/common",
126+
> ```
127+
>
122128
> > [!TIP]
123129
> > To find the values of **Application (client) ID**, **Directory (tenant) ID**, and **Supported account types**, go to the app registration's **Overview** page in the Azure portal.
124130
>
@@ -143,11 +149,17 @@ This quickstart uses MSAL.js 2.0 with the authorization code flow. For a similar
143149
> };
144150
> ```
145151
>
146-
147152
> [!div renderon="docs"]
148153
>
149154
> `Enter_the_Graph_Endpoint_Here` is the endpoint that API calls will be made against. For the main (global) Microsoft Graph API service, enter `https://graph.microsoft.com/` (include the trailing forward-slash). For more information about Microsoft Graph on national clouds, see [National cloud deployment](https://docs.microsoft.com/graph/deployments).
150155
>
156+
> The `graphMeEndpoint` and `graphMailEndpoint` values in the *graphConfig.js* file should be similar to the following if you're using the main (global) Microsoft Graph API service:
157+
>
158+
> ```javascript
159+
> graphMeEndpoint: "https://graph.microsoft.com/v1.0/me",
160+
> graphMailEndpoint: "https://graph.microsoft.com/v1.0/me/messages"
161+
> ```
162+
>
151163
> #### Step 4: Run the project
152164
153165
Run the project with a web server by using Node.js:
@@ -167,7 +179,7 @@ Run the project with a web server by using Node.js:
167179
168180
### How the sample works
169181
170-
![How the sample JavaScript SPA works: 1. The SPA initiates sign in. 2. The SPA acquires an ID token from the Microsoft identity platform. 3. The SPA calls acquire token. 4. The Microsoft identity platform returns an Access token to the SPA. 5. The SPA makes and HTTP GET request with the Access Token to the Microsoft Graph API. 6. The Graph API returns an HTTP response to the SPA.](media/quickstart-v2-javascript/javascriptspa-intro.svg)
182+
:::image type="content" source="media/quickstart-v2-javascript-auth-code/diagram-01-auth-code-flow.png" alt-text="Diagram showing the authorization code flow for a single-page application":::
171183
172184
### msal.js
173185

articles/active-directory/develop/scenario-spa-app-registration.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,19 @@ Follow these steps to add a redirect URI for an app that uses MSAL.js 2.0 or lat
4040

4141
1. In the Azure portal, select the app registration you created earlier in [Create the app registration](#create-the-app-registration).
4242
1. Under **Manage**, select **Authentication**, and then select **Add a platform**.
43-
1. Under **Web applications**, select **Single-page application**.
43+
1. Under **Web applications**, select the **Single-page application** tile.
4444
1. Under **Redirect URIs**, enter a [redirect URI](reply-url.md). Do **NOT** select either checkbox under **Implicit grant**.
4545
1. Select **Configure** to finish adding the redirect URI.
4646

47-
You've now completed the registration of your single-page application (SPA) and configured a redirect URI to which the client will be redirected and any security tokens will be sent. By not selecting either of the settings under **Implicit grant**, your application registration is configured to support the authorization code flow with PKCE and CORS.
47+
You've now completed the registration of your single-page application (SPA) and configured a redirect URI to which the client will be redirected and any security tokens will be sent. By configuring your redirect URI using the **Single-page application** tile in the **Add a platform** pane, your application registration is configured to support the authorization code flow with PKCE and CORS.
4848

4949
## Redirect URI: MSAL.js 1.0 with implicit flow
5050

5151
Follow these steps to add a redirect URI for a single-page app that uses MSAL.js 1.3 or earlier and the implicit grant flow. Applications that use MSAL.js 1.3 or earlier do not support the auth code flow.
5252

5353
1. In the Azure portal, select the app registration you created earlier in [Create the app registration](#create-the-app-registration).
5454
1. Under **Manage**, select **Authentication**, and then select **Add a platform**.
55-
1. Under **Web applications**, select **Single-page application**.
55+
1. Under **Web applications**, select **Single-page application** tile.
5656
1. Under **Redirect URIs**, enter a [redirect URI](reply-url.md).
5757
1. Enable the **Implicit flow**:
5858
- If your application signs in users, select **ID tokens**.
@@ -67,7 +67,7 @@ By default, an app registration created by using single-page application platfor
6767

6868
As mentioned previously, single-page applications using MSAL.js 1.3 are restricted to the implicit grant flow. Current [OAuth 2.0 best practices](v2-oauth2-auth-code-flow.md) recommend using the authorization code flow rather than the implicit flow for SPAs. Having limited-lifetime refresh tokens also helps your application adapt to [modern browser cookie privacy limitations](reference-third-party-cookies-spas.md), like Safari ITP.
6969

70-
When all of your production applications represented by an app registration are using MSAL.js 2.0 and the authorization code flow, uncheck the implicit grant settings in its **Authentication** pane in the Azure portal. Applications using MSAL.js 1.x and the implicit flow can continue to function, however, if you leave the implicit flow enabled (checked).
70+
When all your production single-page applications represented by an app registration are using MSAL.js 2.0 and the authorization code flow, uncheck the implicit grant settings the app registration's **Authentication** pane in the Azure portal. Applications using MSAL.js 1.x and the implicit flow can continue to function, however, if you leave the implicit flow enabled (checked).
7171

7272
## Next steps
7373

articles/active-directory/develop/tutorial-v2-javascript-auth-code.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ MSAL.js 2.0 improves on MSAL.js 1.0 by supporting the authorization code flow in
3131

3232
## How the tutorial app works
3333

34-
![Shows how the sample app generated by this tutorial works](media/active-directory-develop-guidedsetup-javascriptspa-introduction/javascriptspa-intro.svg)
34+
:::image type="content" source="media/tutorial-v2-javascript-auth-code/diagram-01-auth-code-flow.png" alt-text="Diagram showing the authorization code flow in a single-page application":::
3535

3636
The application you create in this tutorial enables a JavaScript SPA to query the Microsoft Graph API by acquiring security tokens from the the Microsoft identity platform endpoint. In this scenario, after a user signs in, an access token is requested and added to HTTP requests in the authorization header. Token acquisition and renewal are handled by the Microsoft Authentication Library for JavaScript (MSAL.js).
3737

@@ -336,6 +336,12 @@ Modify the values in the `msalConfig` section as described here:
336336
- To restrict support to *personal Microsoft accounts only*, replace this value with `consumers`.
337337
- `Enter_the_Redirect_Uri_Here` is `http://localhost:3000`.
338338

339+
The `authority` value in your *authConfig.js* should be similar to the following if you're using the global Azure cloud:
340+
341+
```javascript
342+
authority: "https://login.microsoftonline.com/common",
343+
```
344+
339345
Still in the *app* folder, create a file named *graphConfig.js*. Add the following code to provide your application the configuration parameters for calling the Microsoft Graph API:
340346

341347
```javascript
@@ -352,6 +358,13 @@ Modify the values in the `graphConfig` section as described here:
352358
- For the **global** Microsoft Graph API endpoint, replace both instances of this string with `https://graph.microsoft.com`.
353359
- For endpoints in **national** cloud deployments, see [National cloud deployments](https://docs.microsoft.com/graph/deployments) in the Microsoft Graph documentation.
354360

361+
The `graphMeEndpoint` and `graphMailEndpoint` values in your *graphConfig.js* should be similar to the following if you're using the global endpoint:
362+
363+
```javascript
364+
graphMeEndpoint: "https://graph.microsoft.com/v1.0/me",
365+
graphMailEndpoint: "https://graph.microsoft.com/v1.0/me/messages"
366+
```
367+
355368
## Use Microsoft Authentication Library (MSAL) to sign in user
356369

357370
### Pop-up
@@ -569,23 +582,23 @@ You've completed creation of the application and are now ready to launch the Nod
569582

570583
After the browser loads your *index.html* file, select **Sign In**. You're prompted to sign in with the Microsoft identity platform endpoint:
571584

572-
:::image type="content" source="media/tutorial-v2-javascript-spa/spa-01-signin-dialog.png" alt-text="Web browser displaying sign-in dialog":::
585+
:::image type="content" source="media/tutorial-v2-javascript-auth-code/spa-01-signin-dialog.png" alt-text="Web browser displaying sign-in dialog":::
573586

574587
### Provide consent for application access
575588

576589
The first time you sign in to your application, you're prompted to grant it access to your profile and sign you in:
577590

578-
:::image type="content" source="media/tutorial-v2-javascript-spa/spa-02-consent-dialog.png" alt-text="Content dialog displayed in web browser":::
591+
:::image type="content" source="media/tutorial-v2-javascript-auth-code/spa-02-consent-dialog.png" alt-text="Content dialog displayed in web browser":::
579592

580593
If you consent to the requested permissions, the web applications displays your user name, signifying a successful login:
581594

582-
:::image type="content" source="media/tutorial-v2-javascript-spa/spa-03-signed-in.png" alt-text="Results of a successful sign-in in the web browser":::
595+
:::image type="content" source="media/tutorial-v2-javascript-auth-code/spa-03-signed-in.png" alt-text="Results of a successful sign-in in the web browser":::
583596

584597
### Call the Graph API
585598

586599
After you sign in, select **See Profile** to view the user profile information returned in the response from the call to the Microsoft Graph API:
587600

588-
:::image type="content" source="media/tutorial-v2-javascript-spa/spa-04-see-profile.png" alt-text="Profile information from Microsoft Graph displayed in the browser":::
601+
:::image type="content" source="media/tutorial-v2-javascript-auth-code/spa-04-see-profile.png" alt-text="Profile information from Microsoft Graph displayed in the browser":::
589602

590603
### More information about scopes and delegated permissions
591604

0 commit comments

Comments
 (0)