Реагируйте на JS google-login oauth2, не получайте токен обновления - PullRequest
0 голосов
/ 13 октября 2018

Я пытаюсь интегрировать логин Google с ReactJS с помощью react-google-login и получаю код в ответ, используя этот код, который я хочу 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"}
...