我正在尝试使用Google Auth Exchange代码获取refereh_token, access_token
,浏览文档但它不起作用,我使用的是反应谷歌登录为Auth并获得code
作为回应我正在通过code
https://accounts.google.com/o/oauth2/token但它的给出错误
{
"error": "invalid_grant",
"error_description": "Bad Request"
}
我尝试了很多方法
code=4%2FKxoYTS-jeq5-d6Lv7YvSz9ZrK0pJ_5lZsMExzNC1M0o&redirect_uri=https%3A%2F%2Fdevelopers.google.com%2Foauthplayground&client_id=407408718192.apps.googleusercontent.com&client_secret=************&scope=&grant_type=authorization_code
前端是reactjs,后端是nodejs ..
要使用刷新令牌获取ACCESS令牌,您必须调用api,它将为您提供一个新的访问令牌调用POST APi qazxsw poi
将身体传递为x-www-form-urlencoded即
标题为内容类型:application / x-www-form-urlencoded
身体
client_secret:'xxxxxxxxxxxxdxxxxxSSd'https://www.googleapis.com/oauth2/v4/token
grant_type:refresh_token'
refresh_token:'1 / DDPkddk514451xxxxxxxx'<YourClientSecret>
CLIENT_ID: 'XXXXXXXXX' <YourRefreshToken>
有关更多参考,请阅读此<YourClientID>