diff --git a/bumblebee_status/modules/contrib/gcalendar.py b/bumblebee_status/modules/contrib/gcalendar.py index e438bdd..c88cfad 100644 --- a/bumblebee_status/modules/contrib/gcalendar.py +++ b/bumblebee_status/modules/contrib/gcalendar.py @@ -29,6 +29,7 @@ import core.decorators import datetime import os.path +import pickle from google.auth.transport.requests import Request from google.oauth2.credentials import Credentials @@ -60,7 +61,8 @@ class Module(core.module.Module): # created automatically when the authorization flow completes for the first # time. if os.path.exists(self.__token): - creds = Credentials.from_authorized_user_file(self.__token, SCOPES) + with open(self.__token, 'rb') as token: + creds = pickle.load(token) # 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: @@ -71,8 +73,8 @@ class Module(core.module.Module): ) creds = flow.run_local_server(port=0) # Save the credentials for the next run - with open(self.__token, "w") as token: - token.write(creds.to_json()) + with open(self.__token, 'wb') as token: + pickle.dump(creds, token) try: service = build("calendar", "v3", credentials=creds)