From c98473d118c16bd7a0ac4db35655bd66c9b6ba6c Mon Sep 17 00:00:00 2001 From: Jay Lee Date: Wed, 11 Oct 2017 14:57:38 -0400 Subject: [PATCH] handle SA Drive auth failure on CSV Sheets better --- src/gam.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/gam.py b/src/gam.py index 8e5f4088..0d4f8b76 100755 --- a/src/gam.py +++ b/src/gam.py @@ -9755,7 +9755,15 @@ def writeCSVfile(csvRows, titles, list_type, todrive): if cell_count > 2000000 or columns > 256: print u'{0}{1}'.format(WARNING_PREFIX, MESSAGE_RESULTS_TOO_LARGE_FOR_GOOGLE_SPREADSHEET) mimeType = u'text/csv' - _, drive = buildDrive3GAPIObject(_getValueFromOAuth(u'email')) + admin_email = _getValueFromOAuth(u'email') + _, drive = buildDrive3GAPIObject(admin_email) + if not drive: + print u'''\nGAM is not authorized to create Drive files. Please run: + +gam user %s check serviceaccount + +and follow recommend steps to authorize GAM for Drive access.''' % (admin_email) + sys.exit(5) body = {u'description': u' '.join(sys.argv), u'name': u'%s - %s' % (GC_Values[GC_DOMAIN], list_type), u'mimeType': mimeType}