-
Notifications
You must be signed in to change notification settings - Fork 0
/
graph.js
52 lines (47 loc) · 1.35 KB
/
graph.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// <graphInit>
// Create an options object with the same scopes from the login
const options = new MicrosoftGraph.MSALAuthenticationProviderOptions([
"user.read",
"calendars.read",
"presence.read",
]);
// Create an authentication provider for the implicit flow
const authProvider = new MicrosoftGraph.ImplicitMSALAuthenticationProvider(
msalClient,
options
);
// Initialize the Graph client
const graphClient = MicrosoftGraph.Client.initWithMiddleware({ authProvider });
// </graphInit>
// <getEvents>
async function getEvents() {
try {
let events = await graphClient
.api("/me/events")
.select("subject,organizer,start,end")
.orderby("createdDateTime DESC")
.get();
updatePage(msalClient.getAccount(), Views.calendar, events);
} catch (error) {
updatePage(msalClient.getAccount(), Views.error, {
message: "Error getting events",
debug: error,
});
}
}
// </getEvents>
// <getPresence>
async function getPresence() {
try {
let presence = await graphClient.api("me/presence").version("beta").get();
updatePage(msalClient.getAccount(), Views.presence, presence);
} catch (error) {
updatePage(msalClient.getAccount(), Views.error, {
message: "Error getting presence",
debug: error,
});
}
}
// </getPresence>