Skip to main content

auth-google-one-tap

Documentation / lib/components/AppLayout/auth-google-one-tap

displayGoogleOneTapLogin()

function displayGoogleOneTapLogin(client_id: string, options: object): Promise<boolean>;

Defined in: web-app/src/lib/components/AppLayout/auth-google-one-tap.js:51

Show Google One Tap menu and send JWT userinfo to callback.

The verifyIdToken function verifies the JWT signature, the aud claim, the exp claim, and the iss claim.

Error: If browser blocks due to closing with "FedCM get() rejects with NetworkError" then clear cookies and allow localhost in chrome://settings/content/federatedIdentityApi, or click lock icon in url bar and allow "Third Party Sign In"

Parameters

ParameterTypeDescription

client_id

string

Google OAuth Client ID

options

{ auto_select: boolean; callback_url: string; cancel_on_tap_outside: boolean; state_cookie_domain: string; use_fedcm_for_prompt: boolean; }

options.auto_select?

boolean

If true, the One Tap prompt will immediately return an ID token without user interaction when there is only one Google session.

options.callback_url

string

options.cancel_on_tap_outside?

boolean

If true, the One Tap request will be canceled if the user clicks outside the prompt. If user clicks X it's always off until they click lock icon in url bar and allow "Third Party Sign In"

options.state_cookie_domain?

string

options.use_fedcm_for_prompt?

boolean

If true, the browser will control user sign-in prompts and mediate the sign-in flow between your website and Google.

Returns

Promise<boolean>

true if able to show menu

See

Author

vtempest

Example

if (!user) {
var isOneTapShown = displayGoogleOneTapLogin(
PUBLIC_GOOGLE_CLIENT_ID, {
auto_select: true,
use_fedcm_for_prompt: true,
cancel_on_tap_outside: true,
callback_url: `/auth/google/callback`,
state_cookie_domain: PUBLIC_DOMAIN
})
if (!isOneTapShown)
console.log("OneTap error - use alternatives");
}

loadScript()

function loadScript(url: string): Promise<any>;

Defined in: web-app/src/lib/components/AppLayout/auth-google-one-tap.js:107

Loads a script from the given URL.

Parameters

ParameterTypeDescription

url

string

Returns

Promise<any>