-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
46 lines (42 loc) · 986 Bytes
/
index.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
const google = require("googleapis");
const dotenv = require("dotenv");
dotenv.config();
(async (_) => {
const oauth2Client = new google.Auth.OAuth2Client(
process.env.GOOGLE_CLIENT_ID,
process.env.GOOGLE_CLIENT_SECRET
);
oauth2Client.setCredentials({
refresh_token: process.env.GOOGLE_REFRESH_TOKEN,
});
const calendar = new google.calendar_v3.Calendar({
auth: oauth2Client,
});
const googleEvent = {
title: "Google Calendar",
description: "Google Calendar",
location: "",
start: {
dateTime: new Date(),
timeZone: "America/Los_Angeles",
},
end: {
dateTime: new Date(),
timeZone: "America/Los_Angeles",
},
reminders: {
useDefault: false,
overrides: [
{
method: "popup",
minutes: 10,
},
],
},
colorId: "1",
};
const createdEvent = await calendar.events.insert({
calendarId: "primary",
requestBody: googleEvent,
});
})();