1.1.1 • Published 2 months ago

react-google-login-ng v1.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
2 months ago

React Google Login NG

This is a simple package for use the Google autentication. You can use the Google Button and/or Google One Tap.

Use the most recent GSI library

Install

npm install --save react-google-login-ng

Usage

Import the Google Login Component from react-google-login-ng package

  import GoogleLogin from 'react-google-login-ng'

Then use it in your component like this:

   <GoogleLogin
      client_id='your_client_id_here'
      successCallback={({ credential, select_by }) => {
        console.log(credential, select_by);
      }}
    />

Props

ComponentProps (Extended with T_GoogleConfig type)

RequiredPropTypeDescription
client_idstringGoogle client ID
successCallback(resp: T_ResponseData)=>voidFuntion after google login response
disabledbooleanTo disable login
scriptstringFor load another Google Script
method"one_tap" | "button"If method is not specified, will show One tap and button to do login
configT_ButtonConfig
oneTapListener(Notification)=>voidEvent listener on One Tap Propmpt

T_ResponseData

PropTypeDescription
credentialstringGoogle credential response (JWT)
select_by'auto' | 'user' | "user_1tap" | 'user_1tap' | 'btn' | 'btn_confirm' | 'btn_add_session' | 'btn_confirm_add_session'Type of action of user to login
token_info_urlstringUrl to fetch user data

T_ButtonConfig

RequiredPropTypeDescription
widthnumberButton width
type'standard' | 'icon'
theme'filled_black' | 'outline' | 'filled_blue'
size'large' | 'medium' | 'small'
shape'pill' | 'rectangular'
text'signup_with' | 'signup_with' | 'continue_with' | 'signin'
logo_alignment'center' | 'left'
localestringButton text language
click_listener() => voidFunction when button is clicked

T_ButtonConfig

RequiredPropTypeDescription
auto_selectbooleanThis field determines if an ID token is automatically returned without any user interaction when there's only one Google session that has approved your app before. The default value is false
login_uristring
native_callbackT_ResponseHandler
cancel_on_tap_outsidebooleanThis field sets whether or not to cancel the One Tap request if a user clicks outside the prompt. The default value is true
prompt_parent_idstringThis attribute sets the DOM ID of the container element. If it's not set, the One Tap prompt is displayed in the top-right corner of the window
noncestringThis field is a random string used by the ID token to prevent replay attacks. See the following table for further information
context'use' | 'signup' | 'signin'This field changes the text of the title and messages in the One Tap promp
state_cookie_domainbooleanIf you need to display One Tap in the parent domain and its subdomains, pass the parent domain to this field so that a single shared-state cookie is used
ux_mode'popup' | 'redirect'Use this field to set the UX flow used by the Sign In With Google button. The default value is popup. This attribute has no impact on the OneTap UX
allowed_parent_originstring | string[]The origins that are allowed to embed the intermediate iframe. One Tap will run in the intermediate iframe mode if this field presents
intermediate_iframe_close_callbackstring
itp_supportboolean
use_fedcm_for_promptbooleanDefault: TRUE - It allows the browser to control user sign-in messages and mediates the access flow between your website and Google
login_hintstringTo skip account selection, provide a suggestion for the user. An email address, or the value of an ID token field.sub
hdstringLimit the selection of accounts per domain

Learn More

For more information about Google autentication service, visit the follow GSI link

For more information about Google Configuration params, visit the follow GSI Config props link


1.1.1

2 months ago

1.1.0

2 months ago

1.0.9

2 months ago

1.0.8

2 months ago

1.0.7

9 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago