Package: react-wallet-kit
Defined in: react-wallet-kit/src/providers/client/Types.tsx:212
Overview
Handles the Google OAuth flow.- This function initiates the Google OAuth flow by redirecting the user to the Google authorization page or opening it in a popup window.
- It supports both “popup” and “redirect” flows, determined by the
openInPage
parameter. - Generates a new ephemeral API key pair and uses its public key as the nonce for the OAuth request, ensuring cryptographic binding of the session.
- Constructs the Google OAuth URL with all required parameters, including client ID, redirect URI, response type, scope, nonce, and state.
- The
state
parameter includes the provider, flow type, public key, and any additional state parameters for tracking or custom logic. - If
openInPage
is true, the current page is redirected to the Google OAuth URL and the function returns a promise that resolves on redirect or times out after 5 minutes. - If
openInPage
is false, a popup window is opened for the OAuth flow, and the function returns a promise that resolves when the flow completes or rejects if the window is closed or times out. - On successful authentication, the function either calls the provided
onOauthSuccess
callback, triggers theonOauthRedirect
callback from provider callbacks, or completes the OAuth flow internally by callingcompleteOauth
. - Handles all error cases, including missing configuration, popup failures, and timeouts, and throws a
TurnkeyError
with appropriate error codes.
Parameters
Response
A successful response returns the following fields:A promise that resolves when the OAuth flow is successfully initiated and completed, or rejects on error or timeout.