You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> > 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.
124
130
>
@@ -143,11 +149,17 @@ This quickstart uses MSAL.js 2.0 with the authorization code flow. For a similar
143
149
> };
144
150
> ```
145
151
>
146
-
147
152
> [!div renderon="docs"]
148
153
>
149
154
> `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).
150
155
>
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:
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:
167
179
168
180
### How the sample works
169
181
170
-

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":::
Copy file name to clipboardExpand all lines: articles/active-directory/develop/scenario-spa-app-registration.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff 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
40
40
41
41
1. In the Azure portal, select the app registration you created earlier in [Create the app registration](#create-the-app-registration).
42
42
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.
44
44
1. Under **Redirect URIs**, enter a [redirect URI](reply-url.md). Do **NOT** select either checkbox under **Implicit grant**.
45
45
1. Select **Configure** to finish adding the redirect URI.
46
46
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.
48
48
49
49
## Redirect URI: MSAL.js 1.0 with implicit flow
50
50
51
51
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.
52
52
53
53
1. In the Azure portal, select the app registration you created earlier in [Create the app registration](#create-the-app-registration).
54
54
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.
56
56
1. Under **Redirect URIs**, enter a [redirect URI](reply-url.md).
57
57
1. Enable the **Implicit flow**:
58
58
- 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
67
67
68
68
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.
69
69
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).
Copy file name to clipboardExpand all lines: articles/active-directory/develop/tutorial-v2-javascript-auth-code.md
+18-5Lines changed: 18 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,7 @@ MSAL.js 2.0 improves on MSAL.js 1.0 by supporting the authorization code flow in
31
31
32
32
## How the tutorial app works
33
33
34
-

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":::
35
35
36
36
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).
37
37
@@ -336,6 +336,12 @@ Modify the values in the `msalConfig` section as described here:
336
336
- To restrict support to *personal Microsoft accounts only*, replace this value with `consumers`.
337
337
-`Enter_the_Redirect_Uri_Here` is `http://localhost:3000`.
338
338
339
+
The `authority` value in your *authConfig.js* should be similar to the following if you're using the global Azure cloud:
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:
340
346
341
347
```javascript
@@ -352,6 +358,13 @@ Modify the values in the `graphConfig` section as described here:
352
358
- For the **global** Microsoft Graph API endpoint, replace both instances of this string with `https://graph.microsoft.com`.
353
359
- For endpoints in **national** cloud deployments, see [National cloud deployments](https://docs.microsoft.com/graph/deployments) in the Microsoft Graph documentation.
354
360
361
+
The `graphMeEndpoint` and `graphMailEndpoint` values in your *graphConfig.js* should be similar to the following if you're using the global endpoint:
The first time you sign in to your application, you're prompted to grant it access to your profile and sign you in:
577
590
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":::
579
592
580
593
If you consent to the requested permissions, the web applications displays your user name, signifying a successful login:
581
594
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":::
583
596
584
597
### Call the Graph API
585
598
586
599
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:
587
600
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":::
589
602
590
603
### More information about scopes and delegated permissions
0 commit comments