forked from microsoftgraph/msgraph-sdk-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
72 lines (65 loc) · 1.53 KB
/
Copy pathmain.js
File metadata and controls
72 lines (65 loc) · 1.53 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
window.addEventListener(
"load",
() => {
init();
},
false,
);
let client;
const init = async () => {
const scopes = ["user.read", "profile", "User.ReadWrite", "Files.Read", "Files.Read.All", "Files.ReadWrite", "Files.ReadWrite.All", "Mail.Read", "Mail.ReadWrite", "Mail.Send"];
const msalConfig = {
auth: {
clientId: Secrets.clientId,
redirectUri: "http://localhost:8080",
},
};
var msalApplication = new Msal.UserAgentApplication(msalConfig);
const msalOptions = new MicrosoftGraph.MSALAuthenticationProviderOptions(scopes);
const msalProvider = new MicrosoftGraph.ImplicitMSALAuthenticationProvider(msalApplication, msalOptions);
client = MicrosoftGraph.Client.initWithMiddleware({
debugLogging: true,
authProvider: msalProvider,
});
bindEvents();
};
const bindEvents = () => {
let requestsDOM = document.getElementById("requests");
requestsDOM.addEventListener("click", (elem, event) => {
let id = elem.srcElement.getAttribute("cell");
switch (id) {
case "1":
request
.getUserDetails()
.then((res) => {
ui.updateOutput(res);
})
.catch((error) => {
ui.updateOutput(error);
});
break;
case "2":
request
.getMyDriveFiles()
.then((res) => {
ui.updateOutput(res);
})
.catch((error) => {
ui.updateOutput(error);
});
break;
case "3":
request
.getMyMails()
.then((res) => {
ui.updateOutput(res);
})
.catch((error) => {
ui.updateOutput(error);
});
break;
case "4":
break;
}
});
};