From 228d924e2c727fb0fec4c264e3ff71941ff60f60 Mon Sep 17 00:00:00 2001 From: Jeroen Oudshoorn Date: Fri, 13 Oct 2023 09:19:35 +0200 Subject: [PATCH] v2.4.7 Signed-off-by: Jeroen Oudshoorn --- pwnagotchi/google/cmd.py | 4 ++-- pwnagotchi/plugins/default/gdrivesync.py | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pwnagotchi/google/cmd.py b/pwnagotchi/google/cmd.py index 4cb05d94..d436c334 100644 --- a/pwnagotchi/google/cmd.py +++ b/pwnagotchi/google/cmd.py @@ -67,10 +67,10 @@ def auth(): def refresh(): # refresh token for x amount of time (seconds) - gauth = GoogleAuth(settings_file="settings.yaml") + gauth = GoogleAuth(settings_file="/root/settings.yaml") try: # Try to load saved client credentials - gauth.LoadCredentialsFile("credentials.json") + gauth.LoadCredentialsFile("/root/credentials.json") except pydrive2.auth.InvalidCredentialsError: print(gauth.GetAuthUrl()) user_input = input("Please copy this URL into a browser, " diff --git a/pwnagotchi/plugins/default/gdrivesync.py b/pwnagotchi/plugins/default/gdrivesync.py index eca516a7..91bf33be 100644 --- a/pwnagotchi/plugins/default/gdrivesync.py +++ b/pwnagotchi/plugins/default/gdrivesync.py @@ -53,9 +53,14 @@ class GdriveSync(plugins.Plugin): try: gauth = GoogleAuth(settings_file="/root/settings.yaml") gauth.LoadCredentialsFile("/root/credentials.json") + if gauth.credentials is None: + # Authenticate if they're not there + gauth.LocalWebserverAuth() + elif gauth.access_token_expired: + # Refresh them if expired + gauth.Refresh() gauth.Authorize() - # Create GoogleDrive instance self.drive = GoogleDrive(gauth)