-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate.py
More file actions
30 lines (22 loc) · 866 Bytes
/
create.py
File metadata and controls
30 lines (22 loc) · 866 Bytes
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
from google.oauth2 import service_account
from googleapiclient.discovery import build
# Path to the service account key file
SERVICE_ACCOUNT_FILE = 'path/to/service_account.json'
# Scopes required by the API
SCOPES = ['https://www.googleapis.com/auth/calendar']
creds = service_account.Credentials.from_service_account_file(SERVICE_ACCOUNT_FILE, scopes=SCOPES)
service = build('calendar', 'v3', credentials=creds)
# Creating Calendar Events
event = {
'summary': 'Meeting with HR',
'start': {
'dateTime': '2024-08-01T14:00:00+05:30',
'timeZone': 'Asia/Kolkata',
},
'end': {
'dateTime': '2024-08-01T15:00:00+05:30',
'timeZone': 'Asia/Kolkata',
},
}
event = service.events().insert(calendarId='primary', body=event).execute()
print('Event created: %s' % (event.get('htmlLink')))