Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -20,20 +20,9 @@ from googleapiclient.discovery import build
|
|
| 20 |
# ==== Google Calendar Setup ====
|
| 21 |
SCOPES = ['https://www.googleapis.com/auth/calendar.events']
|
| 22 |
def get_calendar_service():
|
| 23 |
-
creds =
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
if not creds or not creds.valid:
|
| 27 |
-
if creds and creds.expired and creds.refresh_token:
|
| 28 |
-
from google.auth.transport.requests import Request
|
| 29 |
-
creds.refresh(Request())
|
| 30 |
-
else:
|
| 31 |
-
flow = InstalledAppFlow.from_client_secrets_file('credentials.json', SCOPES)
|
| 32 |
-
creds = flow.run_local_server(port=0)
|
| 33 |
-
with open('token.json', 'w') as token:
|
| 34 |
-
token.write(creds.to_json())
|
| 35 |
-
print("✅ token.json saved.")
|
| 36 |
-
return build('calendar', 'v3', credentials=creds)
|
| 37 |
# === Pushover Function ===
|
| 38 |
def send_notification(message):
|
| 39 |
try:
|
|
|
|
| 20 |
# ==== Google Calendar Setup ====
|
| 21 |
SCOPES = ['https://www.googleapis.com/auth/calendar.events']
|
| 22 |
def get_calendar_service():
|
| 23 |
+
creds = Credentials.from_authorized_user_file("token.json", SCOPES)
|
| 24 |
+
return build("calendar", "v3", credentials=creds)
|
| 25 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
# === Pushover Function ===
|
| 27 |
def send_notification(message):
|
| 28 |
try:
|