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)