Skip to content

Commit 846341d

Browse files
committed
serve & use correct version of msal-browser
1 parent 0afc0a9 commit 846341d

4 files changed

Lines changed: 31 additions & 4 deletions

File tree

2-Authorization/0-call-api-vanillajs/SPA/public/authPopup.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22
// configuration parameters are located at authConfig.js
33
const myMSALObj = new msal.PublicClientApplication(msalConfig);
44

5+
myMSALObj.initialize().then(() => {
6+
/**
7+
* A promise handler needs to be registered for handling the
8+
* response returned from redirect flow. For more information, visit:
9+
* https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/initialization.md#redirect-apis
10+
*/
11+
myMSALObj.handleRedirectPromise()
12+
.then(handleResponse)
13+
.catch((error) => {
14+
console.error(error);
15+
});
16+
});
17+
518
let username = '';
619

720
function selectAccount() {

2-Authorization/0-call-api-vanillajs/SPA/public/authRedirect.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22
// configuration parameters are located at authConfig.js
33
const myMSALObj = new msal.PublicClientApplication(msalConfig);
44

5+
myMSALObj.initialize().then(() => {
6+
/**
7+
* A promise handler needs to be registered for handling the
8+
* response returned from redirect flow. For more information, visit:
9+
* https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/initialization.md#redirect-apis
10+
*/
11+
myMSALObj.handleRedirectPromise()
12+
.then(handleResponse)
13+
.catch((error) => {
14+
console.error(error);
15+
});
16+
});
17+
518
let username = '';
619

720
/**

2-Authorization/0-call-api-vanillajs/SPA/public/index.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
<title>Microsoft identity platform</title>
88
<link rel="SHORTCUT ICON" href="./favicon.svg" type="image/x-icon">
99
<link rel="stylesheet" href="./styles.css">
10-
<!-- msal.min.js can be used in the place of msal.js; included msal.js to make debug easy -->
11-
<script id="load-msal" src="https://alcdn.msauth.net/browser/2.31.0/js/msal-browser.js"
12-
integrity="sha384-BO4qQ2RTxj2akCJc7t6IdU9aRg6do4LGIkVVa01Hm33jxM+v2G+4q+vZjmOCywYq"
13-
crossorigin="anonymous"></script>
10+
<!-- msal.min.js can be used in the place of msal-browser.js -->
11+
<script src="/msal-browser.min.js"></script>
1412
<!-- adding Bootstrap 5 for UI components -->
1513
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css" rel="stylesheet"
1614
integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">

2-Authorization/0-call-api-vanillajs/SPA/server.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ app.use(morgan('dev'));
1313
// Setup app folders.
1414
app.use(express.static('public'));
1515

16+
// serve msal-browser module
17+
app.use(express.static(path.join(__dirname, "node_modules/@azure/msal-browser/lib")));
18+
1619
// set up a route for redirect.html
1720
app.get('/redirect', (req, res) => {
1821
res.sendFile(path.join(__dirname + '/public/redirect.html'));

0 commit comments

Comments
 (0)