Skip to content

Commit 8ff9961

Browse files
committed
Updated dependencies
Updated msal-node from alpha to beta
1 parent bbc01c1 commit 8ff9961

5 files changed

Lines changed: 83 additions & 102 deletions

File tree

demo/graph-tutorial/package-lock.json

Lines changed: 39 additions & 66 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/graph-tutorial/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@
66
"start": "node ./bin/www"
77
},
88
"dependencies": {
9-
"@azure/msal-node": "^1.0.0-alpha.5",
10-
"@microsoft/microsoft-graph-client": "^2.0.0",
9+
"@azure/msal-node": "^1.0.0-beta.0",
10+
"@microsoft/microsoft-graph-client": "^2.1.1",
1111
"connect-flash": "^0.1.1",
1212
"cookie-parser": "~1.4.4",
13-
"debug": "^4.1.1",
13+
"debug": "^4.2.0",
1414
"dotenv": "^8.2.0",
1515
"express": "^4.17.1",
1616
"express-promise-router": "^4.0.1",
1717
"express-session": "^1.17.1",
1818
"express-validator": "^6.6.1",
1919
"hbs": "^4.1.1",
2020
"http-errors": "^1.8.0",
21-
"isomorphic-fetch": "^2.2.1",
22-
"moment": "^2.28.0",
21+
"isomorphic-fetch": "^3.0.0",
22+
"moment": "^2.29.1",
2323
"moment-timezone": "^0.5.31",
2424
"morgan": "^1.10.0",
25-
"uuid": "^8.3.0",
25+
"uuid": "^8.3.1",
2626
"windows-iana": "^4.2.1"
2727
}
2828
}

demo/graph-tutorial/routes/calendar.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -179,20 +179,24 @@ router.post('/new', [
179179

180180
async function getAccessToken(userId, msalClient) {
181181
// Look up the user's account in the cache
182-
const accounts = msalClient
183-
.getTokenCache()
184-
.getAllAccounts();
185-
186-
const userAccount = accounts.find(a => a.homeAccountId === userId);
187-
188-
// Get the token silently
189-
const response = await msalClient.acquireTokenSilent({
190-
scopes: process.env.OAUTH_SCOPES.split(','),
191-
redirectUri: process.env.OAUTH_REDIRECT_URI,
192-
account: userAccount
193-
});
194-
195-
return response.accessToken;
182+
try {
183+
const accounts = await msalClient
184+
.getTokenCache()
185+
.getAllAccounts();
186+
187+
const userAccount = accounts.find(a => a.homeAccountId === userId);
188+
189+
// Get the token silently
190+
const response = await msalClient.acquireTokenSilent({
191+
scopes: process.env.OAUTH_SCOPES.split(','),
192+
redirectUri: process.env.OAUTH_REDIRECT_URI,
193+
account: userAccount
194+
});
195+
196+
return response.accessToken;
197+
} catch (err) {
198+
console.log(JSON.stringify(err, Object.getOwnPropertyNames(err)));
199+
}
196200
}
197201

198202
module.exports = router;

tutorial/02-create-app.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ Before moving on, install some additional packages that you will use later:
5555
1. Run the following command in your CLI.
5656
5757
```Shell
58-
npm install dotenv@8.2.0 moment@2.28.0 moment-timezone@0.5.31 connect-flash@0.1.1 express-session@1.17.1 isomorphic-fetch@2.2.1
59-
npm install @azure/msal-node@1.0.0-alpha.5 @microsoft/microsoft-graph-client@2.0.0 windows-iana@4.2.1 express-validator@6.6.1
58+
npm install dotenv@8.2.0 moment@2.29.1 moment-timezone@0.5.31 connect-flash@0.1.1 express-session@1.17.1 isomorphic-fetch@3.0.0
59+
npm install @azure/msal-node@1.0.0-beta.0 @microsoft/microsoft-graph-client@2.1.1 windows-iana@4.2.1 express-validator@6.6.1 uuid@8.3.1
6060
```
6161
6262
> [!TIP]

tutorial/05-add-ms-graph.md

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,24 @@ In this exercise you will incorporate Microsoft Graph into the application. For
8383

8484
async function getAccessToken(userId, msalClient) {
8585
// Look up the user's account in the cache
86-
const accounts = msalClient
87-
.getTokenCache()
88-
.getAllAccounts();
89-
90-
const userAccount = accounts.find(a => a.homeAccountId === userId);
91-
92-
// Get the token silently
93-
const response = await msalClient.acquireTokenSilent({
94-
scopes: process.env.OAUTH_SCOPES.split(','),
95-
redirectUri: process.env.OAUTH_REDIRECT_URI,
96-
account: userAccount
97-
});
98-
99-
return response.accessToken;
86+
try {
87+
const accounts = await msalClient
88+
.getTokenCache()
89+
.getAllAccounts();
90+
91+
const userAccount = accounts.find(a => a.homeAccountId === userId);
92+
93+
// Get the token silently
94+
const response = await msalClient.acquireTokenSilent({
95+
scopes: process.env.OAUTH_SCOPES.split(','),
96+
redirectUri: process.env.OAUTH_REDIRECT_URI,
97+
account: userAccount
98+
});
99+
100+
return response.accessToken;
101+
} catch (err) {
102+
console.log(JSON.stringify(err, Object.getOwnPropertyNames(err)));
103+
}
100104
}
101105

102106
module.exports = router;

0 commit comments

Comments
 (0)