Skip to content

Commit dde1914

Browse files
authored
Merge pull request #188013 from salman90/patch-1
Update msal-js-sso.md
2 parents acc0b7b + 20fe8a6 commit dde1914

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

articles/active-directory/develop/msal-js-sso.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ When your application is open in multiple tabs and you first sign in the user on
3030
By default, MSAL.js uses `sessionStorage`, which doesn't allow the session to be shared between tabs. To get SSO between tabs, make sure to set the `cacheLocation` in MSAL.js to `localStorage` as shown below.
3131

3232
```javascript
33+
3334
const config = {
3435
auth: {
3536
clientId: "abcd-ef12-gh34-ikkl-ashdjhlhsdg",
@@ -39,7 +40,7 @@ const config = {
3940
},
4041
};
4142

42-
const myMSALObj = new UserAgentApplication(config);
43+
const msalInstance = new msal.PublicClientApplication(config);
4344
```
4445

4546
## SSO between apps
@@ -72,8 +73,7 @@ var request = {
7273
sid: sid,
7374
};
7475

75-
userAgentApplication
76-
.acquireTokenSilent(request)
76+
msalInstance.acquireTokenSilent(request)
7777
.then(function (response) {
7878
const token = response.accessToken;
7979
})
@@ -95,7 +95,7 @@ var request = {
9595
extraQueryParameters: { domain_hint: "organizations" },
9696
};
9797

98-
userAgentApplication.loginRedirect(request);
98+
msalInstance.loginRedirect(request);
9999
```
100100

101101
To get the values for login_hint and domain_hint by reading the claims returned in the ID token for the user.
@@ -104,7 +104,7 @@ To get the values for login_hint and domain_hint by reading the claims returned
104104

105105
- **domain_hint** is only required to be passed when using the /common authority. The domain hint is determined by tenant ID(tid). If the `tid` claim in the ID token is `9188040d-6c67-4c5b-b112-36a304b66dad` it's consumers. Otherwise, it's organizations.
106106

107-
For more information about **login_hint** and **domain_hint**, see [Implicit grant flow](v2-oauth2-implicit-grant-flow.md).
107+
For more information about **login_hint** and **domain_hint**, see [auth code grant](v2-oauth2-auth-code-flow.md).
108108

109109
## SSO without MSAL.js login
110110

@@ -125,8 +125,7 @@ var request = {
125125
extraQueryParameters: { domain_hint: "organizations" },
126126
};
127127

128-
userAgentApplication
129-
.acquireTokenSilent(request)
128+
msalInstance.acquireTokenSilent(request)
130129
.then(function (response) {
131130
const token = response.accessToken;
132131
})
@@ -142,6 +141,7 @@ MSAL.js brings feature parity with ADAL.js for Azure AD authentication scenarios
142141
To take advantage of the SSO behavior when updating from ADAL.js, you'll need to ensure the libraries are using `localStorage` for caching tokens. Set the `cacheLocation` to `localStorage` in both the MSAL.js and ADAL.js configuration at initialization as follows:
143142

144143
```javascript
144+
145145
// In ADAL.js
146146
window.config = {
147147
clientId: "g075edef-0efa-453b-997b-de1337c29185",
@@ -160,7 +160,7 @@ const config = {
160160
},
161161
};
162162

163-
const myMSALObj = new UserAgentApplication(config);
163+
const msalInstance = new msal.PublicClientApplication(config);
164164
```
165165

166166
Once the `cacheLocation` is configured, MSAL.js can read the cached state of the authenticated user in ADAL.js and use that to provide SSO in MSAL.js.

0 commit comments

Comments
 (0)