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
Copy file name to clipboardExpand all lines: articles/active-directory/develop/msal-js-pass-custom-state-authentication-request.md
+9-44Lines changed: 9 additions & 44 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,58 +20,23 @@ ms.custom: aaddev
20
20
21
21
The *state* parameter, as defined by OAuth 2.0, is included in an authentication request and is also returned in the token response to prevent cross-site request forgery attacks. By default, the Microsoft Authentication Library for JavaScript (MSAL.js) passes a randomly generated unique *state* parameter value in the authentication requests.
22
22
23
-
The state parameter can also be used to encode information of the app's state before redirect. You can pass the user's state in the app, such as the page or view they were on, as input to this parameter. The MSAL.js library allows you to pass your custom state as state parameter in the `Request` object:
23
+
The state parameter can also be used to encode information of the app's state before redirect. You can pass the user's state in the app, such as the page or view they were on, as input to this parameter. The MSAL.js library allows you to pass your custom state as state parameter in the [Request](https://azuread.github.io/microsoft-authentication-library-for-js/ref/modules/_azure_msal_browser.html#redirectrequest) object. For example:
24
24
25
25
```javascript
26
-
// Request type
27
-
exporttypeAuthenticationParameters= {
28
-
scopes?: Array<string>;
29
-
extraScopesToConsent?: Array<string>;
30
-
prompt?: string;
31
-
extraQueryParameters?: QPDict;
32
-
claimsRequest?: string;
33
-
authority?: string;
34
-
state?: string;
35
-
correlationId?: string;
36
-
account?: Account;
37
-
sid?: string;
38
-
loginHint?: string;
39
-
forceRefresh?: boolean;
40
-
};
41
-
```
42
-
43
-
> [!Note]
44
-
> If you would like to skip a cached token and go to the server, please pass in the boolean `forceRefresh` into the AuthenticationParameters object used to make a login/token request.
45
-
> `forceRefresh` should not be used by default, because of the performance impact on your application.
46
-
> Relying on the cache will give your users a better experience.
47
-
> Skipping the cache should only be used in scenarios where you know the currently cached data does not have up-to-date information.
48
-
> Such as an Admin tool that adds roles to a user that needs to get a new token with updated roles.
The passed in state is appended to the unique GUID set by MSAL.js when sending the request. When the response is returned, MSAL.js checks for a state match and then returns the custom passed in state in the `Response` object as `accountState`.
62
-
63
-
```javascript
64
-
exporttypeAuthResponse= {
65
-
uniqueId: string;
66
-
tenantId: string;
67
-
tokenType: string;
68
-
idToken: IdToken;
69
-
accessToken: string;
70
-
scopes: Array<string>;
71
-
expiresOn: Date;
72
-
account: Account;
73
-
accountState: string;
74
-
};
75
-
```
40
+
The passed in state is appended to the unique GUID set by MSAL.js when sending the request. When the response is returned, MSAL.js checks for a state match and then returns the custom passed in state in the [Response](https://azuread.github.io/microsoft-authentication-library-for-js/ref/modules/_azure_msal_common.html#authenticationresult) object as `state`.
76
41
77
-
To learn more, read about [building a single-page application (SPA)](scenario-spa-overview.md) using MSAL.js.
42
+
To learn more, read about [building a single-page application (SPA)](scenario-spa-overview.md) using MSAL.js.
0 commit comments