0.2.17 • Published 1 year ago

google-login-react v0.2.17

Weekly downloads
-
License
-
Repository
github
Last release
1 year 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

1 year ago

0.2.16

1 year ago

0.2.15

1 year ago

0.2.14

1 year ago

0.2.13

1 year ago

0.2.12

1 year ago

0.2.11

1 year ago

0.2.10

1 year ago

0.1.0

1 year ago

0.2.1

1 year ago

0.1.2

1 year ago

0.2.0

1 year ago

0.1.1

1 year ago

0.2.7

1 year ago

0.1.8

1 year ago

0.2.6

1 year ago

0.1.7

1 year ago

0.2.8

1 year ago

0.1.9

1 year ago

0.2.3

1 year ago

0.1.4

1 year ago

0.2.2

1 year ago

0.1.3

1 year ago

0.2.5

1 year ago

0.1.6

1 year ago

0.2.4

1 year ago

0.1.5

1 year ago

0.0.6

4 years ago