From 42ed5509ee4d35862ba46420b3bd260f6eb2c4c5 Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Thu, 16 Mar 2023 09:31:20 -0700 Subject: [PATCH] Updates/cleanup (#1614) * Handle socks error when checking local time offset * Keep pylint happy * Avoid trap when authentication flow blows up * Fix bug that causes trap on create project --- src/gam/__init__.py | 12 ++++++++++-- src/gam/auth/__init__.py | 8 +++----- src/gam/auth/oauth.py | 20 ++++++++++++++------ 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/gam/__init__.py b/src/gam/__init__.py index 2ac8f0d2..8a306116 100755 --- a/src/gam/__init__.py +++ b/src/gam/__init__.py @@ -636,8 +636,10 @@ TIME_OFFSET_UNITS = [('day', 86400), ('hour', 3600), ('minute', 60), def getLocalGoogleTimeOffset(testLocation='admin.googleapis.com'): + # If local time is well off, it breaks https because the server certificate + # will be seen as too old or new and thus invalid; http doesn't have that issue. # Try with http first, if time is close ( 0: sleep(0.1) if not http_client.is_alive(): - user_input.terminate() - break - elif not user_input.is_alive(): + if 'code' in d: + user_input.terminate() + break + alive -= 1 + if not user_input.is_alive(): userInput = True - http_client.terminate() - break + if 'code' in d: + http_client.terminate() + break + alive -= 1 + if 'code' not in d: + controlflow.system_error_exit(8, MESSAGE_AUTHENTICATION_FAILED) while True: code = d['code'] if code.startswith('http'):