React-google-login: signIn null or undefined

Created on 28 Sep 2018  路  4Comments  路  Source: anthonyjgrove/react-google-login

I have next code
render={(renderProps: any) => ( <a onClick={renderProps.onClick()} className="link-google auth-link" title="Google" > <i className="fi flaticon-google-plus-logo" /> </a> )}

and have error only in IE11 signIn null or undefined

Most helpful comment

I have same issue google-login.js:1 - Uncaught TypeError: Cannot read property 'signIn' of null on Google Chrome 69
<GoogleLogin clientId={CONFIG.googleId} buttonText="Login" onSuccess={this.handleGoogleResponse} onFailure={this.handleGoogleResponse} />

All 4 comments

I have same issue google-login.js:1 - Uncaught TypeError: Cannot read property 'signIn' of null on Google Chrome 69
<GoogleLogin clientId={CONFIG.googleId} buttonText="Login" onSuccess={this.handleGoogleResponse} onFailure={this.handleGoogleResponse} />

@RomaMoisiuk add please code for method handleGoogleResponse

@pogran

handleGoogleResponse = (response) => {
    const tokenBlob = new Blob([JSON.stringify({access_token: response.accessToken}, null, 2)], {type: 'application/json'});
    const options = {
      method: 'POST',
      body: tokenBlob,
      mode: 'cors',
      cache: 'default'
    };
    fetch(`${CONFIG.api_url}/auth/google`, options).then((r) => {
      const token = r.headers.get('x-auth-token');
      r.json().then((user) => {
        if (token) {
          this.setState({isAuthenticated: true, user, token})
          window.location.href = `${CONFIG.ui_home}`;
        }
      });
    })
  };

Closing Due to Inactivity

Was this page helpful?
0 / 5 - 0 ratings