Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 验证用户帐户后,刷新令牌为空_Python 3.x_Google Oauth - Fatal编程技术网

Python 3.x 验证用户帐户后,刷新令牌为空

Python 3.x 验证用户帐户后,刷新令牌为空,python-3.x,google-oauth,Python 3.x,Google Oauth,我正在验证用户帐户,并将详细信息写入json文件以连接到云。如何获取刷新令牌 {"refresh_token": null, "token_uri": "https://oauth2.googleapis.com/token", "client_id": "13465789222- tmd611m4j6ofdpsvp25t59s2gf6im4ed.apps.googleusercontent.com", "client_secret": "HCdEIght0997j5iL2ewi2vUnM-"

我正在验证用户帐户,并将详细信息写入json文件以连接到云。如何获取刷新令牌

{"refresh_token": null,
"token_uri": "https://oauth2.googleapis.com/token",
"client_id": "13465789222- 
tmd611m4j6ofdpsvp25t59s2gf6im4ed.apps.googleusercontent.com",
"client_secret": "HCdEIght0997j5iL2ewi2vUnM-", 
"scopes": ["https://www.googleapis.com/auth/cloud-platform"]}
下面是我的代码,它执行身份验证并将详细信息存储在json中

try:
    with open(file, 'r') as infile:
        creds = json.load(infile)
except FileNotFoundError:
    return ''
except json.decoder.JSONDecodeError:
    return ''

credentials = google.oauth2.credentials.Credentials(
    'access_token',
    refresh_token=creds['refresh_token'],
    token_uri=creds['token_uri'],
    client_id=creds['client_id'],
    client_secret=creds['client_secret'],
    scopes=creds['scopes'])

refresh_token = creds['refresh_token']
print(refresh_token)
return credentials
我正在为刷新令牌获取null

{"refresh_token": null,
"token_uri": "https://oauth2.googleapis.com/token",
"client_id": "13465789222- 
tmd611m4j6ofdpsvp25t59s2gf6im4ed.apps.googleusercontent.com",
"client_secret": "HCdEIght0997j5iL2ewi2vUnM-", 
"scopes": ["https://www.googleapis.com/auth/cloud-platform"]}

你在范围内提供了离线访问吗?嗨,Sagar,我对这种与云相关的东西非常陌生。我不确定什么是作用域脱机访问在拥有脱机访问作用域之前,您不能刷新令牌。使用此作用域:[“”,“脱机访问”]我们如何能够拥有脱机访问,如果您愿意,请提供更多详细信息。您是否在作用域中提供脱机访问?嗨,Sagar,我对这种与云相关的事情非常陌生。我不确定什么是作用域脱机访问在拥有脱机访问作用域之前,您无法刷新令牌。使用此作用域:[“”,“脱机访问”]我们如何可以进行脱机访问,如果您有,请提供更多详细信息