react-google-login-component
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/react-google-login-component package

0.9.3 • Public • Published

react-google-login-component

React Google Component to log users in through google

version MIT License

react-google-login-component is a module that easily lets you drop it into your existing project and get the benefits of Google Login. It's a plug and play component that'll fit in your workflow if your using standalone React or React with Redux.

You can find login with Facebook here

Up to date with the latest API Version

Usage

npm install --save react-google-login-component
import React from 'react';
import { GoogleLogin } from 'react-google-login-component';
 
class Login extends React.Component{
 
  constructor (props, context) {
    super(props, context);
  }
 
  responseGoogle (googleUser) {
    var id_token = googleUser.getAuthResponse().id_token;
    var googleId = googleUser.getId();
    
    console.log({ googleId });
    console.log({accessToken: id_token});
    //anything else you want to do(save to localStorage)...
  }
 
  render () {
    return (
      <div>
        <GoogleLogin socialId="yourClientID"
                     className="google-login"
                     scope="profile"
                     fetchBasicProfile={false}
                     responseHandler={this.responseGoogle}
                     buttonText="Login With Google"/>
      </div>
    );
  }
 
}
 
export default Login;
 

Package Sidebar

Install

npm i react-google-login-component

Weekly Downloads

560

Version

0.9.3

License

MIT

Unpacked Size

61.1 kB

Total Files

23

Last publish

Collaborators

  • kennetpostigo
  • koss-lebedev