From a8d2165a07494ac83cda0c02399b1a5916b8ae0b Mon Sep 17 00:00:00 2001 From: Rafayel Hovhannisyan Date: Fri, 11 Apr 2025 14:24:51 +0000 Subject: [PATCH] feat(one-tap): add context prop to useGoogleOneTapLogin --- README.md | 1 + .../@react-oauth/google/src/hooks/useGoogleOneTapLogin.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/README.md b/README.md index 8950702..add9b54 100644 --- a/README.md +++ b/README.md @@ -269,3 +269,4 @@ const hasAccess = hasGrantedAnyScopeGoogle( | | hosted_domain | `string` | If your application knows the Workspace domain the user belongs to, use this to provide a hint to Google. For more information, see the [hd](https://developers.google.com/identity/protocols/oauth2/openid-connect#authenticationuriparameters) field in the OpenID Connect docs | | | disabled | `boolean` | Controls whether to cancel the popup in cases such as when the user is already logged in | | | use_fedcm_for_prompt | `boolean` | Allow the browser to control user sign-in prompts and mediate the sign-in flow between your website and Google. | +| | context | `signin` \| `signup` \| `use` | The title and words in the One Tap prompt | diff --git a/packages/@react-oauth/google/src/hooks/useGoogleOneTapLogin.ts b/packages/@react-oauth/google/src/hooks/useGoogleOneTapLogin.ts index 7330a05..e4d1661 100644 --- a/packages/@react-oauth/google/src/hooks/useGoogleOneTapLogin.ts +++ b/packages/@react-oauth/google/src/hooks/useGoogleOneTapLogin.ts @@ -20,6 +20,7 @@ interface UseGoogleOneTapLoginOptions { disabled?: boolean; use_fedcm_for_prompt?: IdConfiguration['use_fedcm_for_prompt']; auto_select?: boolean; + context?: IdConfiguration['context']; } export default function useGoogleOneTapLogin({ @@ -33,6 +34,7 @@ export default function useGoogleOneTapLogin({ use_fedcm_for_prompt = false, disabled, auto_select, + context, }: UseGoogleOneTapLoginOptions): void { const { clientId, scriptLoadedSuccessfully } = useGoogleOAuth(); @@ -73,6 +75,7 @@ export default function useGoogleOneTapLogin({ state_cookie_domain, use_fedcm_for_prompt, auto_select, + context, }); window?.google?.accounts?.id?.prompt(promptMomentNotificationRef.current); @@ -90,5 +93,6 @@ export default function useGoogleOneTapLogin({ use_fedcm_for_prompt, disabled, auto_select, + context, ]); }