Skip to content

Commit 85c49bf

Browse files
authored
Add Support for FedCM Button Flow (#387)
1 parent 498cf95 commit 85c49bf

File tree

5 files changed

+19
-1
lines changed

5 files changed

+19
-1
lines changed

.changeset/real-suns-build.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@react-oauth/google": patch
3+
---
4+
5+
Add support for FedCM Button Flow

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ const hasAccess = hasGrantedAnyScopeGoogle(
228228
| | itp_support | `boolean` | Enables upgraded One Tap UX on ITP browsers |
229229
| | 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 |
230230
| | 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. |
231+
| | use_fedcm_for_button | `boolean` | Enable FedCM Button flow. |
231232

232233
### useGoogleLogin (Both implicit & authorization code flow)
233234

@@ -269,3 +270,4 @@ const hasAccess = hasGrantedAnyScopeGoogle(
269270
| | 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 |
270271
| | disabled | `boolean` | Controls whether to cancel the popup in cases such as when the user is already logged in |
271272
| | 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. |
273+
| | use_fedcm_for_button | `boolean` | Enable FedCM Button flow. |

packages/@react-oauth/google/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ const hasAccess = hasGrantedAnyScopeGoogle(
226226
| | itp_support | `boolean` | Enables upgraded One Tap UX on ITP browsers |
227227
| | 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 |
228228
| | 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. |
229+
| | use_fedcm_for_button | `boolean` | Enable FedCM Button flow. |
229230

230231
### useGoogleLogin (Both implicit & authorization code flow)
231232

@@ -267,3 +268,4 @@ const hasAccess = hasGrantedAnyScopeGoogle(
267268
| | 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 |
268269
| | disabled | `boolean` | Controls whether to cancel the popup in cases such as when the user is already logged in |
269270
| | 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. |
271+
| | use_fedcm_for_button | `boolean` | Enable FedCM Button flow. |

packages/@react-oauth/google/src/hooks/useGoogleOneTapLogin.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { useEffect, useRef } from 'react';
22

33
import { useGoogleOAuth } from '../GoogleOAuthProvider';
4-
import { extractClientId } from '../utils';
54
import type {
65
CredentialResponse,
76
GoogleCredentialResponse,
87
IdConfiguration,
98
MomentListener,
109
} from '../types';
10+
import { extractClientId } from '../utils';
1111

1212
interface UseGoogleOneTapLoginOptions {
1313
onSuccess: (credentialResponse: CredentialResponse) => void;
@@ -19,6 +19,7 @@ interface UseGoogleOneTapLoginOptions {
1919
hosted_domain?: string;
2020
disabled?: boolean;
2121
use_fedcm_for_prompt?: IdConfiguration['use_fedcm_for_prompt'];
22+
use_fedcm_for_button?: IdConfiguration['use_fedcm_for_button'];
2223
auto_select?: boolean;
2324
}
2425

@@ -31,6 +32,7 @@ export default function useGoogleOneTapLogin({
3132
state_cookie_domain,
3233
hosted_domain,
3334
use_fedcm_for_prompt = false,
35+
use_fedcm_for_button = false,
3436
disabled,
3537
auto_select,
3638
}: UseGoogleOneTapLoginOptions): void {
@@ -72,6 +74,7 @@ export default function useGoogleOneTapLogin({
7274
prompt_parent_id,
7375
state_cookie_domain,
7476
use_fedcm_for_prompt,
77+
use_fedcm_for_button,
7578
auto_select,
7679
});
7780

@@ -88,6 +91,7 @@ export default function useGoogleOneTapLogin({
8891
state_cookie_domain,
8992
hosted_domain,
9093
use_fedcm_for_prompt,
94+
use_fedcm_for_button,
9195
disabled,
9296
auto_select,
9397
]);

packages/@react-oauth/google/src/types/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ export interface IdConfiguration {
5454
* @default false
5555
*/
5656
use_fedcm_for_prompt?: boolean;
57+
/**
58+
* Enable FedCM Button flow
59+
* @default false
60+
*/
61+
use_fedcm_for_button?: boolean;
5762
}
5863

5964
export interface CredentialResponse {

0 commit comments

Comments
 (0)