React JS google-login oauth2没有获得刷新令牌

时间:2018-10-13 10:52:56

标签: reactjs google-api-nodejs-client

我正在尝试通过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"}

0 个答案:

没有答案