another change to improve missing scope errors

This commit is contained in:
Jay Lee
2016-11-01 22:23:34 -04:00
parent 4129e05f5e
commit 3fa6cde6b0

View File

@ -960,7 +960,8 @@ def callGAPI(service, function,
handleOAuthTokenError(e, soft_errors or GAPI_SERVICE_NOT_AVAILABLE in throw_reasons) handleOAuthTokenError(e, soft_errors or GAPI_SERVICE_NOT_AVAILABLE in throw_reasons)
if GAPI_SERVICE_NOT_AVAILABLE in throw_reasons: if GAPI_SERVICE_NOT_AVAILABLE in throw_reasons:
raise GAPI_serviceNotAvailable(e.message) raise GAPI_serviceNotAvailable(e.message)
entityUnknownWarning(u'User', GM_Globals[GM_CURRENT_API_USER], 0, 0) print u'ERROR: user %s: %s' % (GM_Globals[GM_CURRENT_API_USER], e)
#entityUnknownWarning(u'User', GM_Globals[GM_CURRENT_API_USER], 0, 0)
return None return None
except httplib2.CertificateValidationUnsupported: except httplib2.CertificateValidationUnsupported:
noPythonSSLExit() noPythonSSLExit()
@ -1169,7 +1170,6 @@ def buildGAPIServiceObject(api, act_as, use_scopes=None):
credentials = getSvcAcctCredentials(use_scopes, act_as) credentials = getSvcAcctCredentials(use_scopes, act_as)
try: try:
service._http = credentials.authorize(http) service._http = credentials.authorize(http)
service._http.request.credentials.refresh(httplib2.Http(disable_ssl_certificate_validation=GC_Values[GC_NO_VERIFY_SSL]))
except httplib2.ServerNotFoundError as e: except httplib2.ServerNotFoundError as e:
systemErrorExit(4, e) systemErrorExit(4, e)
except oauth2client.client.AccessTokenRefreshError as e: except oauth2client.client.AccessTokenRefreshError as e:
@ -1205,7 +1205,7 @@ def doCheckServiceAccount(users):
try: try:
service = buildGAPIServiceObject(api, act_as=user, use_scopes=scope) service = buildGAPIServiceObject(api, act_as=user, use_scopes=scope)
service._http.request.credentials.refresh(httplib2.Http(disable_ssl_certificate_validation=GC_Values[GC_NO_VERIFY_SSL])) service._http.request.credentials.refresh(httplib2.Http(disable_ssl_certificate_validation=GC_Values[GC_NO_VERIFY_SSL]))
result = u'pass' result = u'PASS'
except oauth2client.client.HttpAccessTokenRefreshError: except oauth2client.client.HttpAccessTokenRefreshError:
result = u'FAIL' result = u'FAIL'
print u'Scope: {0:60} {1}'.format(scope, result) print u'Scope: {0:60} {1}'.format(scope, result)