Undo serialization using picke, added comment on minimum version for google-api-python-client

This commit is contained in:
Diego Pereyra 2022-08-11 12:26:04 -03:00
parent 80efa64614
commit 2b3b9c0ca0

View file

@ -14,7 +14,7 @@ Parameters:
* gcalendar.locale: locale to use rather than the system default.
Requires these pip packages:
* google-api-python-client
* google-api-python-client >= 1.8.0
* google-auth-httplib2
* google-auth-oauthlib
"""
@ -30,7 +30,6 @@ import core.decorators
import datetime
import os.path
import pickle
import locale
from google.auth.transport.requests import Request
@ -72,8 +71,7 @@ class Module(core.module.Module):
# created automatically when the authorization flow completes for the first
# time.
if os.path.exists(self.__token):
with open(self.__token, 'rb') as token:
creds = pickle.load(token)
creds = Credentials.from_authorized_user_file(self.__token, 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:
@ -84,8 +82,8 @@ class Module(core.module.Module):
)
creds = flow.run_local_server(port=0)
# Save the credentials for the next run
with open(self.__token, 'wb') as token:
pickle.dump(creds, token)
with open(self.__token, "w") as token:
token.write(creds.to_json())
try:
service = build("calendar", "v3", credentials=creds)