我正在尝试通过react-google-login
将Google登录与ReactJS集成在一起,并使用我想要的代码refresh_token
来获取代码作为响应,但我却没有得到错误提示:
<GoogleLogin
clientId=""
scope="openid"
redirectUri="http://localhost:3005/auth/google/callback"
onSuccess={this._handleGoogleLoginSuccess}
onFailure={this.googleFail}
response_type="code"
accessType="offline"
prompt="consent" >
_handleGoogleLoginSuccess (response) {
// sucessfully get code and used code call api
fetch('https://api.box.com/oauth2/token', {
method: 'post',
headers: {
'Content-Type': 'application/json'
},
body: {
code:response.code,
client_id:"xxxxxxxxx",
client_secret: "xxxxx",
redirect_uri:"http://localhost:3005/auth/google/callback",
grant_type:'authorization_code'
},
}).then(function (response){ return response.json()})
.then(function(token) {
console.log("token................",token);
}.bind(this));
}
But my get error occure
{"error": "invalid_grant", "error_description": "Bad Request"}