Skip to content

Commit 2a05d80

Browse files
authored
fix(GoogleLogin): add state property (#398)
1 parent 4bcf494 commit 2a05d80

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

.changeset/tiny-singers-swim.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@react-oauth/google': minor
3+
---
4+
5+
Added natively supported state property to GoogleLogin component

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ const hasAccess = hasGrantedAnyScopeGoogle(
221221
| | native_callback | `(response: { id: string; password: string }) => void` | The JavaScript password credential handler function name |
222222
| | prompt_parent_id | `string` | The DOM ID of the One Tap prompt container element |
223223
| | nonce | `string` | A random string for ID tokens |
224+
| | state | `string` | This string returns with the ID token |
224225
| | context | `signin` \| `signup` \| `use` | The title and words in the One Tap prompt |
225226
| | state_cookie_domain | `string` | If you need to call One Tap in the parent domain and its subdomains, pass the parent domain to this attribute so that a single shared cookie is used |
226227
| | allowed_parent_origin | `string` \| `string[]` | The origins that are allowed to embed the intermediate iframe. One Tap will run in the intermediate iframe mode if this attribute presents |

packages/@react-oauth/google/src/GoogleLogin.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export default function GoogleLogin({
3535
width,
3636
locale,
3737
click_listener,
38+
state,
3839
containerProps,
3940
...props
4041
}: GoogleLoginProps) {
@@ -80,6 +81,7 @@ export default function GoogleLogin({
8081
width,
8182
locale,
8283
click_listener,
84+
state,
8385
});
8486

8587
if (useOneTap)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ export interface GsiButtonConfiguration {
100100
locale?: string;
101101
/** If set, this [function](https://developers.google.com/identity/gsi/web/reference/js-reference#click_listener) will be called when the Sign in with Google button is clicked. */
102102
click_listener?: () => void;
103+
/** If set, this [string](https://developers.google.com/identity/gsi/web/reference/js-reference#state) returns with the ID token. */
104+
state?: string;
103105
}
104106

105107
export interface PromptMomentNotification {

0 commit comments

Comments
 (0)