-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.html
126 lines (108 loc) · 3.92 KB
/
index.html
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<!DOCTYPE html>
<html>
<head>
<title>Switch: Outlook</title>
<meta charset='utf-8' />
<link rel="stylesheet" href="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-core/4.1.0/css/fabric.min.css">
<link rel="stylesheet" href="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-js/1.4.0/css/fabric.min.css" />
<link rel="stylesheet" href="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-js/1.4.0/css/fabric.components.min.css" />
<style>
body {
max-width: 1200px;
margin: 30px auto;
}
.ms-DetailsList {
max-width: 450px;
margin: 30px auto;
}
.ms-DetailsList td {
vertical-align: -webkit-baseline-middle;
}
td.ms-DetailsRow-cell:nth-of-type(1) {
margin: 0 0 0 15px;
}
td.ms-DetailsRow-cell:nth-of-type(2) {
width: 30%;
}
tr:first-of-type {
border-bottom: 1px solid #2488d8;
}
</style>
</head>
<body class="ms-u-textAlignCenter">
<h1 class="ms-fontSize-su ms-fontColor-themePrimary">Switch: Outlook </h1>
<p class="ms-fontSize-xxl">Convert your Gmail filters to Outlook rules</p>
<p class="ms-fontSize-xl">This app needs permission to access these accounts</p>
<p><a href="switch.html">Switch: Gmail</a></p>
<table class="ms-DetailsList ms-u-borderBase ms-fontSize-xl ms-u-textAlignLeft">
<tr class="ms-DetailsRow" tabindex="0">
<td class="ms-DetailsRow-cell ms-fontWeight-semibold">
<i class="ms-Icon ms-Icon--Mail ms-fontSize-su" aria-hidden="true"></i>
</td>
<td class="ms-DetailsRow-cell ms-fontWeight-semibold">
Gmail
</td>
<td class="ms-DetailsRow-cell">to access your filters</td>
</tr>
<tr class="ms-DetailsRow" tabindex="1">
<td class="ms-DetailsRow-cell ms-fontWeight-semibold">
<i class="ms-Icon ms-Icon--Mail ms-fontSize-su" aria-hidden="true"></i>
</td>
<td class="ms-DetailsRow-cell ms-fontWeight-semibold">
Outlook
</td>
<td class="ms-DetailsRow-cell">to create rules</td>
</tr>
</table>
<button id="authaad" onclick="login('aad');" class="ms-Button ms-Button--primary">
<span class="ms-Button-label">Connect to Outlook</span>
</button>
<pre class="response"></pre>
<script src="https://cdnjs.cloudflare.com/ajax/libs/hellojs/2.0.0-1/hello.all.js"></script>
<script src="aad.js"></script>
<script src="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-js/1.4.0/js/fabric.min.js"></script>
<script type="text/javascript">
function login(network){
// By defining response type to code, the OAuth flow that will return a refresh token to be used to refresh the access token
// However this will require the oauth_proxy server
hello(network).login({display: 'popup'}, log).then(function() {
alert('You are connected to Outlook');
// Change button to Sign Out
var authButton = document.getElementById('auth'+network);
authButton.innerHTML = 'Disconnect from Outlook';
authButton.setAttribute('onclick', 'logout("'+network+'");');
}, function(e) {
alert('Signin error: ' + e.error.message);
});
}
function logout(network){
// Removes all sessions, need to call AAD endpoint to do full logout
hello(network).logout({force: true}, log).then(function() {
alert('You have diconnected from Outlook');
// Change button to Sign in
var authButton = document.getElementById('auth');
authButton.innerHTML = "Connect to Outlook";
authButton.setAttribute('onclick', 'login("aad");');
}, function(e) {
alert('Sign out error: ' + e.error.message);
});
}
// function api(network) {
// // api in hello.js allows you to make API calls w/ the new Bearer Token
// hello(network).api('me').then(function(data) {
// alert("Data: " + data.toString());
// });
// }
// TODO: Register your app and put your client/app id below
hello.init({
aad : `3b5fc765-b59f-43d7-961e-d8d81765d11b`
},{
redirect_uri: '../index.html',
scope: 'mailboxsettings.readwrite'
});
function log(s){
document.body.querySelector('.response').appendChild(document.createTextNode("\n\n" + JSON.stringify(s, true, 2)));
}
</script>
</body>
</html>