From 6248958c945125239fc2e2a4d4848f26bf17afa5 Mon Sep 17 00:00:00 2001 From: Jay Lee Date: Thu, 19 Dec 2019 13:44:07 -0500 Subject: [PATCH] cleanup --- src/gam.py | 6 ++++++ src/var.py | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/gam.py b/src/gam.py index ae58d074..8bbd6a29 100755 --- a/src/gam.py +++ b/src/gam.py @@ -1081,6 +1081,12 @@ def getValidOauth2TxtCredentials(force_refresh=False): writeCredentials(credentials) break except google.auth.exceptions.RefreshError as e: + try: + if e.args[0] in REFRESH_PERM_ERRORS: + # remove OAuth file so we kick off auth next time + os.remove(GC_Values[GC_OAUTH2_TXT]) + except SyntaxError: + pass controlflow.system_error_exit(18, str(e)) except (google.auth.exceptions.TransportError, httplib2.ServerNotFoundError, RuntimeError) as e: if n != retries: diff --git a/src/var.py b/src/var.py index 1417107e..e10cc6a2 100644 --- a/src/var.py +++ b/src/var.py @@ -450,6 +450,11 @@ DOCUMENT_FORMATS_MAP = { {'mime': 'application/vnd.oasis.opendocument.text', 'ext': '.odt'}], } +REFRESH_PERM_ERRORS = [ + 'invalid_grant: reauth related error (rapt_required)', # no way to reauth today + 'invalid_grant: Token has been expired or revoked.', + ] + DNS_ERROR_CODES_MAP = { 1: 'DNS Query Format Error', 2: 'Server failed to complete the DNS request',