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'):