Skip to main content

Module API

Constants

statusCodes

Read more about the status codes here.

Const statusCodes: Readonly<{ IN_PROGRESS: string ; NO_SAVED_CREDENTIAL_FOUND: string ; ONE_TAP_START_FAILED: string ; PLAY_SERVICES_NOT_AVAILABLE: string ; SIGN_IN_CANCELLED: string ; SIGN_IN_REQUIRED: string }>

Functions

isErrorWithCode

isErrorWithCode(error): error is NativeModuleError

TypeScript helper to check if an object has the code property. This is used to avoid as casting when you access the code property on errors returned by the module.

Parameters

NameType
errorany

Returns

error is NativeModuleError

One-tap sign in module

OneTapSignInParams

Ƭ OneTapSignInParams: Object

NameTypeDescription
webClientIdstringThe web client ID obtained from Google Cloud console.
iosClientId?stringThe iOS client ID obtained from Google Cloud console. Provide this if you're not using the config file from Firebase.
nonce?stringOptional. random string used by the ID token to prevent replay attacks.
autoSignIn?booleanOptional. If true, enables auto sign-in.
filterByAuthorizedAccounts?booleanOptional. Filters by authorized accounts.

The following are available on the Web. Read the value descriptions here.

NameTypeDescription
login_uri?string
native_callback?() => void
cancel_on_tap_outside?boolean
prompt_parent_id?string
context?"signin" | "signup" | "use"
state_cookie_domain?string
ux_mode?"popup" | "redirect"
allowed_parent_origin?string | string[]
intermediate_iframe_close_callback?() => void
itp_support?boolean
log_level?"debug" | "info" | "warn"

OneTapUser

Ƭ OneTapUser: Object

NameTypeDescription
userThe signed-in user object.
user.idstringThe unique identifier of the user.
user.emailstring | nullThe email of the user, if available.
user.namestring | nullThe full name of the user, if available.
user.givenNamestring | nullThe given name (first name) of the user, if available.
user.familyNamestring | nullThe family name (last name) of the user, if available.
user.photostring | nullThe URL to the user's photo, if available.
idTokenstringThe ID token for the user.
credentialOrigin"auto" | "user" | "user_1tap" | "user_2tap" | "btn" | "btn_confirm" | "btn_add_session" | "btn_confirm_add_session"The origin of the credential selection. Always 'user' in native apps.

GoogleOneTapSignIn

Const GoogleOneTapSignIn: Object

The entry point of the One-tap Sign In API, exposed as GoogleOneTapSignIn. On Android, this module uses the Android Credential Manager under the hood.

On the web, don't call signIn / createAccount and use the WebGoogleOneTapSignIn.signIn instead. The signOut method is available on all platforms.

Type declaration

NameType
signIn(params: OneTapSignInParams) => Promise<OneTapUser>
presentExplicitSignIn(params: OneTapSignInParams) => Promise<OneTapUser>
createAccount(params: OneTapSignInParams) => Promise<OneTapUser>
signOut(emailOrUniqueId: string) => Promise<null>

Web One-tap sign in module

This is a wrapper for the Sign In with Google for Web, supporting both the One-tap flow and the Google Sign-In button.

WebGoogleOneTapSignIn

Const WebGoogleOneTapSignIn: Object

On the web, call WebGoogleOneTapSignIn.signIn on page load or other window events, not as a response to a user interaction.

That sets up a listener for authentication events and calls the appropriate callbacks.

On other platforms, it calls the onError callback with a SIGN_IN_CANCELLED error.

Type declaration

NameType
signIn(params: OneTapSignInParams, callbacks: WebOneTapSignInCallbacks) => void

WebOneTapSignInCallbacks

Ƭ WebOneTapSignInCallbacks: Object

Type declaration

NameTypeDescription
momentListener?MomentListenerA callback function that is called when important events take place. See reference.
onError(error: NativeModuleError) => void | Promise<void>Called when the user cancels the sign-in flow, or when an error occurs. You can use the code property of the error to determine the reason for the error. The reported errors on the web are in the same format as the errors reported on the native platforms, so you can reuse your error handling code.
onSuccess(userInfo: OneTapUser) => void | Promise<void>Called when the user successfully signs in, either using the One-tap flow or the button flow.

Original Google sign in

AddScopesParams

Ƭ AddScopesParams: Object

Type declaration

NameTypeDescription
scopesstring[]The Google API scopes to request access to. Default is email and profile.

ConfigureParams

Ƭ ConfigureParams: Object

Type declaration

NameTypeDescription
webClientId?stringWeb client ID from Developer Console. Required to get the idToken on the user object, and for offline access.
accountName?stringANDROID ONLY. An account name that should be prioritized.
forceCodeForRefreshToken?booleanANDROID ONLY. If true, the granted server auth code can be exchanged for an access token and a refresh token.
hostedDomain?stringSpecifies a hosted domain restriction
offlineAccess?booleanMust be true if you wish to access user APIs on behalf of the user from your own server
openIdRealm?stringiOS ONLY The OpenID2 realm of the home web server. This allows Google to include the user's OpenID Identifier in the OpenID Connect ID token.
profileImageSize?numberiOS ONLY The desired height (and width) of the profile image. Defaults to 120px
scopes?string[]The Google API scopes to request access to. Default is email and profile.
googleServicePlistPath?stringIf you want to specify a different bundle path name for the GoogleService-Info, e.g. 'GoogleService-Info-Staging'. Mutualy exclusive with iosClientId
iosClientId?stringIf you want to specify the client ID of type iOS. Mutualy exclusive with googleServicePlistPath.

GetTokensResponse

Ƭ GetTokensResponse: Object

Type declaration

NameType
accessTokenstring
idTokenstring

HasPlayServicesParams

Ƭ HasPlayServicesParams: Object

Type declaration

NameTypeDescription
showPlayServicesUpdateDialogbooleanOptional. Whether to show a dialog that promps the user to install Google Play Services, if they don't have them installed

SignInParams

Ƭ SignInParams: Object

Type declaration

NameTypeDescription
loginHint?stringiOS only. The user's ID, or email address, to be prefilled in the authentication UI if possible. See docs here

User

Ƭ User: Object

Type declaration

NameTypeDescription
idTokenstring | nullJWT (JSON Web Token) that serves as a secure credential for your user's identity.
scopesstring[]-
serverAuthCodestring | nullNot null only if a valid webClientId and offlineAccess: true was specified in configure().
user{ email: string ; familyName: string | null ; givenName: string | null ; id: string ; name: string | null ; photo: string | null }-
user.emailstring-
user.familyNamestring | null-
user.givenNamestring | null-
user.idstring-
user.namestring | null-
user.photostring | null-

GoogleSignin

Const GoogleSignin: Object

The entry point of the Google Sign In API, exposed as GoogleSignin.

Type declaration

NameType
addScopes(options: AddScopesParams) => Promise<User | null>
clearCachedAccessToken(tokenString: string) => Promise<null>
configure(options: ConfigureParams) => void
getCurrentUser() => User | null
getTokens() => Promise<GetTokensResponse>
hasPlayServices(options: HasPlayServicesParams) => Promise<boolean>
hasPreviousSignIn() => boolean
revokeAccess() => Promise<null>
signIn(options: SignInParams) => Promise<User>
signInSilently() => Promise<User>
signOut() => Promise<null>

React Components

GoogleSigninButton: Object

GoogleSigninButtonProps

Ƭ GoogleSigninButtonProps: Object

Type declaration

Also inherits ViewProps.

NameType
color?"dark" | "light"
disabled?boolean
onPress?() => void
size?number

WebGoogleSignInButtonProps

Ƭ WebGoogleSignInButtonProps: Object

NameTypeDescription
type?"standard" | "icon"Optional. The type of the sign-in button.
theme?"outline" | "filled_blue" | "filled_black"Optional. The theme of the sign-in button.
size?"large" | "medium" | "small"Optional. The size of the sign-in button.
text?"signin_with" | "signup_with" | "continue_with" | "signin"Optional. The text to display on the sign-in button.
shape?"rectangular" | "pill" | "circle" | "square"Optional. The shape of the sign-in button.
width?numberOptional. The width of the sign-in button.
locale?stringOptional. The locale for the sign-in button.
logoAlignment?"left" | "center"Optional. The alignment of the logo on the button.

GoogleSigninButton

GoogleSigninButton(props): Element

Parameters

NameType
propsGoogleSigninButtonProps

Returns

Element


WebGoogleSigninButton

WebGoogleSigninButton(props): Element

Parameters

NameType
propsWebGoogleSignInButtonProps

Returns

Element