0.2.17 • Published 3 years ago

google-login-react v0.2.17

Weekly downloads
-
License
-
Repository
github
Last release
3 years ago

Google Login React

Google Login using the new Google Authentication SDK

Install

$ npm install google-login-react

# or

$ yarn add google-login-react

Usage

Usage with default button

import { GoogleLogin } from 'google-login-react-ts';

const App = () => {
  return (
    <GoogleLogin
      clientId='<your_client_id>'
      onSuccess={(res) => console.log(res)}
      onError={(err) => console.log(err)}
    />
  );
}

Usage with custom button

import { GoogleLogin } from 'google-signin-react-ts';

const App = () => {
  return (
    <GoogleLogin
      clientId='<your_client_id>'
      onSuccess={(res) => console.log(res)}
      onError={(err) => console.log(err)}
      containerClass="<your_custom_class>"
    >
      <button>Google Login</button>
    </GoogleLogin>
  )
}

Usage with render

import { GoogleLogin } from 'google-signin-react-ts';

const App = () => {
  return (
    <GoogleLogin
      clientId='<your_client_id>'
      onSuccess={(res) => console.log(res)}
      onError={(err) => console.log(err)}
      containerClass="<your_custom_class>"
      render={(renderProps) => (
        <button onClick={renderProps.onClick}>Google Login</button>
      )}
    />
  )
}

API

GoogleLogin

RequiredPropertyTypeDescription
clientIdstringGoogle Project Client ID
containerClassbooleanContainer className
onSuccess(response: GoogleResponse) => voidCallback fires after successful login
onError(response: Error) => voidCallback fires after unsuccessful login
scopestringGoogle scopes
childrenelementElement that replaces default button
render({ onClick }) => voidRender JSX Element passing onClick function
userInfoFetchURLstring | defaultURL to retrive Google User info

Response

Google Successful Response

  {
    "email": "...",
    "email_verified": "...",
    "family_name": "...",
    "given_name": "...",
    "locale": "...",
    "name": "...",
    "picture": "...",
    "sub": "..."
  }
PropertyTypeDescription
emailstringGoogle user email
email_verifiedbooleanGoogle user email is verified
family_namestringGoogle user family name
given_namestringGoogle user given name
localestringGoogle user locale
namestringGoogle user name
picturestringGoogle user picture URL
substringGoogle user sub ID
0.2.17

3 years ago

0.2.16

3 years ago

0.2.15

3 years ago

0.2.14

3 years ago

0.2.13

3 years ago

0.2.12

3 years ago

0.2.11

3 years ago

0.2.10

3 years ago

0.1.0

3 years ago

0.2.1

3 years ago

0.1.2

3 years ago

0.2.0

3 years ago

0.1.1

3 years ago

0.2.7

3 years ago

0.1.8

3 years ago

0.2.6

3 years ago

0.1.7

3 years ago

0.2.8

3 years ago

0.1.9

3 years ago

0.2.3

3 years ago

0.1.4

3 years ago

0.2.2

3 years ago

0.1.3

3 years ago

0.2.5

3 years ago

0.1.6

3 years ago

0.2.4

3 years ago

0.1.5

3 years ago

0.0.6

5 years ago