我对python具有这样的授权:
def return_token():
return get_oauth2_token()
def disable_stout():
o_stdout = sys.stdout
o_file = open(os.devnull, 'w')
sys.stdout = o_file
return (o_stdout, o_file)
def enable_stout(o_stdout, o_file):
o_file.close()
sys.stdout = o_stdout
def get_oauth2_token():
CLIENT_ID = '123'
CLIENT_SECRET = '123'
SCOPE = \
'https://www.googleapis.com/auth/plus.login ' + \
'https://www.googleapis.com/auth/plus.me ' + \
'https://www.googleapis.com/auth/userinfo.email ' + \
'https://www.googleapis.com/auth/userinfo.profile ' + \
'https://mail.google.com/ ' + \
'https://www.googleapis.com/auth/gmail.readonly ' + \
'https://www.googleapis.com/auth/gmail.settings.basic'
REDIRECT_URI = 'http://localhost:8080'
o_stdout, o_file = disable_stout()
flow = OAuth2WebServerFlow(
client_id=CLIENT_ID,
client_secret=CLIENT_SECRET,
scope=SCOPE,
redirect_uri=REDIRECT_URI)
storage = Storage('creds.data')
credentials = run_flow(flow, storage)
enable_stout(o_stdout, o_file)
print("access_token: %s" % credentials.access_token)
print("refresh_token: %s" % credentials.refresh_token)
if __name__ == '__main__':
return_token()
此代码的工作和授权返回访问和刷新令牌。仅当我具有 access 和 refresh 令牌时,后端中的所有逻辑才起作用。
前端开发人员使用react-native-google-signin
库,该库不返回 refresh 令牌。我有一个问题:refresh token
可以得到access token
吗?