-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauthorize.js
45 lines (42 loc) · 1.1 KB
/
authorize.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
var Promise = TrelloPowerUp.Promise;
var t = TrelloPowerUp.iframe();
var authenticationSuccess = function() {
Trello.get('members/me',{fields:'username'}, function(data) {
$.ajax({
method: "GET",
url: "https://trello-snooze-webhook.herokuapp.com/auth?id="+data.id+"&username="+data.username+"&value="+Trello.token()
})
.done(function( msg ) {
t.set('board', 'private', 'auth', 'true')
.then(function() {
t.set('board', 'private', 'id', data.id)
.then(function() {
t.closePopup();
})
})
})
}, function(err) {
if (err.status === 401) {
Trello.deauthorize();
t.popup({
title: "Authorize",
url: './authorize.html'
});
}
})
};
var authenticationFailure = function() {
console.log("Failed authentication");
};
document.getElementById('authorize').addEventListener('click', function(){
Trello.authorize({
type: "popup",
name: "SnoozeCards",
scope: {
read: true,
write: true },
expiration: "never",
success: authenticationSuccess,
error: authenticationFailure
});
})