Skip to content

Commit

Permalink
get adding events to calendar working
Browse files Browse the repository at this point in the history
  • Loading branch information
ByteOfKathy committed Feb 1, 2023
1 parent 991713b commit ea7cfea
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,30 +152,28 @@ def loginGoogle() -> Credentials:
Returns credentials if possible, otherwise none for an error
"""
creds = None
scopes = [
"https://www.google.com/calendar/feeds",
"https://www.googleapis.com/auth/gmail.modify",
]
if os.path.exists("token.json"):
creds = Credentials.from_authorized_user_file(
"token.json",
scopes=[
"https://www.googleapis.com/auth/calendar",
"https://www.googleapis.com/auth/gmail.modify",
],
scopes = scopes,
)
# If there are no (valid) credentials available, let the user log in.
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
try:
creds.refresh(Request())
except Exception as e:
glados_speak("How are you holding up? ... BECAUSE I'M A POTATO THAT CAN'T ACCESS YOUR CALENDAR")
glados_speak("How are you holding up? ... BECAUSE I'M A POTATO. THAT CAN'T ACCESS YOUR CALENDAR")
print(e)
return
else:
flow = InstalledAppFlow.from_client_secrets_file(
"google_creds.json",
scopes=[
"https://www.googleapis.com/auth/calendar",
"https://www.googleapis.com/auth/gmail.modify",
],
scopes = scopes,
)
creds = flow.run_local_server(port=0)
# Save the credentials for the next run
Expand Down

0 comments on commit ea7cfea

Please sign in to comment.