From f9b7286f76f72247320cfa98579199d7fa7e7f3c Mon Sep 17 00:00:00 2001 From: Pseudo Channel Date: Mon, 24 Jul 2017 17:48:57 -0700 Subject: [PATCH] Need to generate credentials via the google python tut then move the .credentials folder to home folder of controller. --- src/GoogleCalendar.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/GoogleCalendar.py b/src/GoogleCalendar.py index 216ebaa..64fa2f4 100644 --- a/src/GoogleCalendar.py +++ b/src/GoogleCalendar.py @@ -7,6 +7,9 @@ from oauth2client import client from oauth2client import tools from oauth2client.file import Storage +import os.path as path +import sys + import datetime """try: @@ -20,8 +23,11 @@ class GoogleCalendar(): # If modifying these scopes, delete your previously saved credentials # at ~/.credentials/calendar-python-quickstart.json + two_up = path.abspath(path.join(__file__ ,"../../../")) + home_dir = os.path.expanduser('~') + credential_dir = os.path.join(home_dir, 'client_secret.json') SCOPES = 'https://www.googleapis.com/auth/calendar.readonly' - CLIENT_SECRET_FILE = 'client_secret.json' + CLIENT_SECRET_FILE = credential_dir APPLICATION_NAME = 'Google Calendar API Python Quickstart' KEY = '' @@ -48,6 +54,7 @@ class GoogleCalendar(): store = Storage(credential_path) credentials = store.get() + if not credentials or credentials.invalid: flow = client.flow_from_clientsecrets(self.CLIENT_SECRET_FILE, self.SCOPES) flow.user_agent = self.APPLICATION_NAME