From 3e8bb878c825e4cb96472e7c405e19aac85dc0e0 Mon Sep 17 00:00:00 2001 From: Jay Lee Date: Fri, 21 Nov 2014 08:39:27 -0500 Subject: [PATCH] catch unauthorized client and show service account instructions --- gam.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gam.py b/gam.py index 08385807..26dda538 100644 --- a/gam.py +++ b/gam.py @@ -614,7 +614,7 @@ def buildGAPIServiceObject(api, act_as=None, soft_errors=False): try: return googleapiclient.discovery.build(api, version, http=http) except oauth2client.client.AccessTokenRefreshError, e: - if e.message == u'access_denied': + if e.message in [u'access_denied', u'unauthorized_client: Unauthorized client or scope in request.']: print u'Error: Access Denied. Please make sure the Client Name:\n\n%s\n\nis authorized for the API Scope(s):\n\n%s\n\nThis can be configured in your Control Panel under:\n\nSecurity -->\nAdvanced Settings -->\nManage third party OAuth Client access' % (SERVICE_ACCOUNT_CLIENT_ID, ','.join(scope)) sys.exit(5) else: