def doOAuthRequest():
client_id, client_secret = getOAuthClientIDAndSecret()
login_hint = getEmailAddress(noUid=True, optional=True)
checkForExtraneousArguments()
selectedScopes = getScopesFromUser()
if selectedScopes is None:
return
login_hint = getValidateLoginHint(login_hint)
revokeCredentials(API.FAM_LIST)
flags = cmd_flags(noLocalWebserver=GC.Values[GC.NO_BROWSER])
httpObj = httplib2.Http(disable_ssl_certificate_validation=GC.Values[GC.NO_VERIFY_SSL])
for cred_family in API.FAM_LIST:
scopes = [API.EMAIL_SCOPE, API.PROFILE_SCOPE] # Email Display Scope, always included for client
i = 0
for a_scope in API.OAUTH2_SCOPES:
if cred_family == a_scope[u'credfam']:
if selectedScopes[i] == u'*':
scopes.append(a_scope[u'scope'])
elif selectedScopes[i] == u'R':
scopes.append(u'{0}.readonly'.format(a_scope[u'scope']))
elif selectedScopes[i] == u'A':
scopes.append(u'{0}.action'.format(a_scope[u'scope']))
i += 1
flow = oauth2client.client.OAuth2WebServerFlow(client_id=client_id,
client_secret=client_secret, scope=scopes, redirect_uri=oauth2client.client.OOB_CALLBACK_URN,
user_agent=GAM_INFO, response_type=u'code', login_hint=login_hint)
storage = getCredentialsForScope(cred_family, storageOnly=True)
try:
oauth2client.tools.run_flow(flow=flow, storage=storage, flags=flags, http=httpObj)
time.sleep(3)
except httplib2.CertificateValidationUnsupported:
noPythonSSLExit()
entityActionPerformed([Ent.OAUTH2_TXT_FILE, GC.Values[GC.OAUTH2_TXT]])
评论列表
文章目录