This commit is contained in:
Jay Lee
2017-04-17 10:42:19 -04:00
2 changed files with 14 additions and 6 deletions

View File

@@ -493,7 +493,7 @@ def doGAMVersion(checkForArgs=True):
doGAMCheckForUpdates(forceCheck=True)
def handleOAuthTokenError(e, soft_errors):
if e in OAUTH2_TOKEN_ERRORS or e.startswith(u'Invalid response'):
if e.replace(u'.', u'') in OAUTH2_TOKEN_ERRORS or e.startswith(u'Invalid response'):
if soft_errors:
return None
if not GM_Globals[GM_CURRENT_API_USER]:
@@ -6687,7 +6687,7 @@ def doCreateProject(login_hint=None):
print u'Ooops!!\n\n%s\n\nIs not a valid client ID. Please make sure you are following the directions exactly and that there are no extra spaces in your client ID.' % client_id
return False
if content[u'error_description'] == u'Unauthorized':
print u'Ooops!!\n\n%s\n\nIis not a valid client secret. Please make sure you are following the directions exactly and that there are no extra spaces in your client secret.' % client_secret
print u'Ooops!!\n\n%s\n\nIs not a valid client secret. Please make sure you are following the directions exactly and that there are no extra spaces in your client secret.' % client_secret
return False
print u'Unknown error: %s' % content
return False
@@ -7048,7 +7048,7 @@ def doUpdateUser(users, i):
body[u'emails'] = [{u'type': u'custom', u'customType': u'former_employee', u'primary': False, u'address': user_primary}]
sys.stdout.write(u'updating user %s...\n' % user)
if body:
callGAPI(cd.users(), u'patch', userKey=user, body=body)
callGAPI(cd.users(), u'update', userKey=user, body=body)
if admin_body:
callGAPI(cd.users(), u'makeAdmin', userKey=user, body=admin_body)

View File

@@ -697,9 +697,17 @@ MESSAGE_SERVICE_NOT_APPLICABLE = u'Service not applicable for this address: {0}.
MESSAGE_INSTRUCTIONS_OAUTH2SERVICE_JSON = u'Please run\n\ngam create project\ngam user <user> check serviceaccount\n\nto create and configure a service account.'
MESSAGE_OAUTH2SERVICE_JSON_INVALID = u'The file {0} is missing required keys (client_email, client_id or private_key). Please remove it and recreate with the commands:\n\ngam create project\ngam user <user> check serviceaccount'
# oauth errors
OAUTH2_TOKEN_ERRORS = [u'access_denied', u'unauthorized_client: Unauthorized client or scope in request.', u'access_denied: Requested client not authorized.',
u'invalid_grant: Not a valid email.', u'invalid_grant: Invalid email or User ID', u'invalid_grant: Bad Request',
u'invalid_request: Invalid impersonation prn email address.', u'internal_failure: Backend Error']
OAUTH2_TOKEN_ERRORS = [
u'access_denied',
u'access_denied: Requested client not authorized',
u'internal_failure: Backend Error',
u'invalid_grant: Bad Request',
u'invalid_grant: Invalid email or User ID',
u'invalid_grant: Not a valid email',
u'invalid_request: Invalid impersonation prn email address',
u'unauthorized_client: Client is unauthorized to retrieve access tokens using this method',
u'unauthorized_client: Unauthorized client or scope in request',
]
#
# callGAPI throw reasons
GAPI_BACKEND_ERROR = u'backendError'