f6a4415a
Apichat.Tum
start smart-rms-c...
|
1
2
3
|
'use strict';
const google = require('googleapis');
|
d360cefc
TUM.Apichat
move save google ...
|
4
|
const googleAuth = require('google-auth-library');
|
f6a4415a
Apichat.Tum
start smart-rms-c...
|
5
6
|
const calendar = google.calendar('v3');
|
f6a4415a
Apichat.Tum
start smart-rms-c...
|
7
|
const fs = require('fs');
|
a54f2679
DESKTOP-RBJDHSM\ADMIN
fix API
|
8
9
10
|
const SCOPES = [process.env.SCOPES];
const TOKEN_DIR = (process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE) + '/.credentials/';
|
77034810
Apichat.Tum
fix REST API
|
11
|
const TOKEN_PATH = TOKEN_DIR + 'calendar-nodejs-quickstart.json';
|
d360cefc
TUM.Apichat
move save google ...
|
12
13
14
|
module.exports = {
|
fbe7f7a7
Apichat.Tum
add api google
|
15
16
17
18
19
20
21
22
23
|
authorize: (callback) => {
fs.readFile('client_secret.json', function processClientSecrets(err, content) {
if (err) {
console.log('Error loading client secret file: ' + err);
return;
}
let credentials = JSON.parse(content);
|
f3f14fef
TUM.Apichat
add value config ...
|
24
|
var clientSecret = credentials.installed.client_secret;
|
fbe7f7a7
Apichat.Tum
add api google
|
25
26
27
28
29
30
31
|
var clientId = credentials.installed.client_id;
var redirectUrl = credentials.installed.redirect_uris[0];
var auth = new googleAuth();
var oauth2Client = new auth.OAuth2(clientId, clientSecret, redirectUrl);
// Check if we have previously stored a token.
fs.readFile(TOKEN_PATH, function (err, token) {
|
f6a4415a
Apichat.Tum
start smart-rms-c...
|
32
|
if (err) {
|
d360cefc
TUM.Apichat
move save google ...
|
33
|
return callback(err);
|
f6a4415a
Apichat.Tum
start smart-rms-c...
|
34
35
36
|
} else {
oauth2Client.credentials = JSON.parse(token);
return callback(null, oauth2Client);
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
37
38
39
40
41
42
43
44
|
}
});
});
},
getNewToken: (oauth2Client, callback) => {
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
var authUrl = oauth2Client.generateAuthUrl({
access_type: 'offline',
scope: SCOPES
});
console.log('Authorize this app by visiting this url: ', authUrl);
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question('Enter the code from that page here: ', function (code) {
rl.close();
oauth2Client.getToken(code, function (err, token) {
if (err) {
console.log('Error while trying to retrieve access token', err);
return;
}
oauth2Client.credentials = token;
storeToken(token);
callback(oauth2Client);
});
});
|
d360cefc
TUM.Apichat
move save google ...
|
66
67
68
|
},
listEvents: (auth, callback) => {
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
69
|
calendar.events.list({
|
d360cefc
TUM.Apichat
move save google ...
|
70
71
72
73
|
auth: auth,
calendarId: process.env.CALENDAR_ID,
timeMin: (new Date()).toISOString(),
maxResults: 50,
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
74
|
singleEvents: true,
|
d360cefc
TUM.Apichat
move save google ...
|
75
|
orderBy: 'startTime'
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
76
|
}, (err, response) => {
|
d360cefc
TUM.Apichat
move save google ...
|
77
|
if (err) {
|
48a9a246
Apichat.Tum
fix auth
|
78
|
return callback(err);
|
d360cefc
TUM.Apichat
move save google ...
|
79
80
81
82
83
84
85
86
87
88
89
90
91
|
}
return callback(null, response);
});
},
createEvent: (auth, event, callback) => {
calendar.events.insert({
auth: auth,
calendarId: process.env.CALENDAR_ID,
resource: event,
}, (err, event) => {
if (err) {
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
92
93
|
return callback('There was an error contacting the Calendar service: ' + err);
}
|
f6a4415a
Apichat.Tum
start smart-rms-c...
|
94
|
return callback(null, event.htmlLink);
|
f6a4415a
Apichat.Tum
start smart-rms-c...
|
95
|
});
|
fbe7f7a7
Apichat.Tum
add api google
|
96
97
|
}
}
|
f3f14fef
TUM.Apichat
add value config ...
|
|
|
fbe7f7a7
Apichat.Tum
add api google
|
|
|
f6a4415a
Apichat.Tum
start smart-rms-c...
|
|
|
a54f2679
DESKTOP-RBJDHSM\ADMIN
fix API
|
|
|
f6a4415a
Apichat.Tum
start smart-rms-c...
|
|
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
|
|
fbe7f7a7
Apichat.Tum
add api google
|
|
|
f3f14fef
TUM.Apichat
add value config ...
|
|
|
fbe7f7a7
Apichat.Tum
add api google
|
|
|
48a9a246
Apichat.Tum
fix auth
|
|
|
fbe7f7a7
Apichat.Tum
add api google
|
|
|
48a9a246
Apichat.Tum
fix auth
|
|
|
fbe7f7a7
Apichat.Tum
add api google
|
|
|
48a9a246
Apichat.Tum
fix auth
|
|
|
fbe7f7a7
Apichat.Tum
add api google
|
|
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
|
|
f6a4415a
Apichat.Tum
start smart-rms-c...
|
|
|
fbe7f7a7
Apichat.Tum
add api google
|
|
|
f6a4415a
Apichat.Tum
start smart-rms-c...
|
|
|
a54f2679
DESKTOP-RBJDHSM\ADMIN
fix API
|
|
|
f6a4415a
Apichat.Tum
start smart-rms-c...
|
|
|
a54f2679
DESKTOP-RBJDHSM\ADMIN
fix API
|
|
|
f6a4415a
Apichat.Tum
start smart-rms-c...
|
|
|
a54f2679
DESKTOP-RBJDHSM\ADMIN
fix API
|
|
|
f6a4415a
Apichat.Tum
start smart-rms-c...
|
|
|
a54f2679
DESKTOP-RBJDHSM\ADMIN
fix API
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
7598c58f
Apichat.Tum
add eventTypeID /...
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
a54f2679
DESKTOP-RBJDHSM\ADMIN
fix API
|
|
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
|
|
21a1ff19
Apichat.Tum
fix follow smartr...
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
21a1ff19
Apichat.Tum
fix follow smartr...
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
21a1ff19
Apichat.Tum
fix follow smartr...
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
21a1ff19
Apichat.Tum
fix follow smartr...
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
7598c58f
Apichat.Tum
add eventTypeID /...
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
1244ae71
Apichat.Tum
new response
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
fbe7f7a7
Apichat.Tum
add api google
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
fbe7f7a7
Apichat.Tum
add api google
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
fbe7f7a7
Apichat.Tum
add api google
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
fbe7f7a7
Apichat.Tum
add api google
|
|
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
|
|
77034810
Apichat.Tum
fix REST API
|
|
|
fbe7f7a7
Apichat.Tum
add api google
|
|
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
|
|
21a1ff19
Apichat.Tum
fix follow smartr...
|
|
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
|
|
21a1ff19
Apichat.Tum
fix follow smartr...
|
|
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
|
|
7598c58f
Apichat.Tum
add eventTypeID /...
|
|
|
1244ae71
Apichat.Tum
new response
|
|
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
|
|
a54f2679
DESKTOP-RBJDHSM\ADMIN
fix API
|
|
|
cf86e9a3
Apichat.Tum
- ui with oauth2 ...
|
|
|
a54f2679
DESKTOP-RBJDHSM\ADMIN
fix API
|
|
|
fbe7f7a7
Apichat.Tum
add api google
|
|
|
f3f14fef
TUM.Apichat
add value config ...
|
|
|
fbe7f7a7
Apichat.Tum
add api google
|
|
|
f6a4415a
Apichat.Tum
start smart-rms-c...
|
|
|
fbe7f7a7
Apichat.Tum
add api google
|
|
|