"unsupported_grant_type"来自谷歌刷新访问令牌(离线访问)API



根据文档,如果你想刷新你的访问令牌,你可以对"https://oauth2.googleapis.com/token"提供client_id、client_secret、grant_type、refresh_token。

代码:

user = User.query.filter_by(email='daniyaldehleh@gmail.com').first()  
with open('client_secret.json') as d:
d = json.load(d)
thecredentials = { 
'client_id': d['web']['client_id'],
'client_secret':d['web']['client_secret'],
'refresh_token':user.refresh,
'grant_type': user.refresh,
'redirect_uri': "http://localhost:5000/",
'access_type':'offline'
}
req = requests.post(url='https://oauth2.googleapis.com/token', data = thecredentials)
print(req.text)
return str(req)

尽管根据一些研究添加了"redirect_uri"one_answers"access_type",但我还是继续获得:

{
"error": "unsupported_grant_type",
"error_description": "Invalid grant_type: 1//04JBbHWUWxwS3CgYIARAAGAQSNwF-L9IrZyyrHpxIoerJ4XZkAuGosXeeRHiYvdEQG7uF5EO5jWSC_-9mrRMAhmM30JHZvgyIhbM"
}

对于使用刷新令牌,授予类型应为:grant_type = refresh_token

请参阅https://developers.google.com/android-publisher/authorization#using_the_refresh_token

最新更新