Skip to main content

Types

import type {
AuthorizationResult,
GoogleSession,
GoogleSignInConfiguration,
GoogleTokens,
GoogleUser,
SignInResult,
SignInResultType,
} from 'nitro-google-signin'

GoogleSignInConfiguration​

Configures the OAuth clients and the sign-in request. Passed to configure. Every field is optional.

FieldTypeDescription
webClientIdstringThe Web application OAuth client ID of your backend. ID tokens are issued for this audience, and server auth codes are exchanged with it. Defaults to GIDServerClientID in the iOS Info.plist and the Android default_web_client_id string resource.
iosClientIdstringThe iOS OAuth client ID. Defaults to GIDClientID in Info.plist, then to CLIENT_ID in GoogleService-Info.plist. Its reversed form must be registered as a URL scheme. Ignored on Android.
requestOfflineAccessbooleanRequests a one-time serverAuthCode from interactive sign-in and requestScopes. Defaults to false.
hostedDomainstringRestricts sign-in to accounts of this Google Workspace domain, such as example.com. Validate the hd claim on your backend as well.
noncestringThe nonce embedded in the ID token. A random nonce is generated for each request when omitted.
scopesstring[]Full OAuth scope URLs requested at sign-in in addition to openid, email and profile.
enableAutoSelectbooleanLets signIn finish without UI when exactly one authorized account exists. Defaults to false. Android only; iOS restores the previous user without UI either way.

GoogleSession​

A signed-in Google account and the credentials issued for it.

FieldTypeDescription
userGoogleUserThe signed-in account's profile.
scopesstring[]The OAuth scopes granted to this app, including openid, email and profile. Check it before calling requestScopes.
idTokenstringThe OpenID Connect ID token (JWT). Verify it on your backend.
serverAuthCodestring?A one-time code your backend exchanges for a refresh token. Present only after an interactive sign-in with requestOfflineAccess; never stored or restored.

GoogleUser​

The Google account profile of a session.

FieldTypeDescription
idstringThe stable Google account ID, the sub claim of the ID token. Use it as the account key instead of the email.
emailstring?The account's email address, absent when the email scope was not granted.
namestring?The full display name.
givenNamestring?The given (first) name.
familyNamestring?The family (last) name.
photostring?The profile picture URL.

GoogleTokens​

Fresh tokens of the signed-in user, from getTokens.

FieldTypeDescription
idTokenstringThe OpenID Connect ID token (JWT).
accessTokenstringAn OAuth access token for the granted scopes.

AuthorizationResult​

Credentials for the scopes granted by requestScopes.

FieldTypeDescription
accessTokenstringAn OAuth access token for calling Google APIs from the device.
serverAuthCodestring?A one-time OAuth code for your backend, present with requestOfflineAccess.
scopesstring[]Every scope now granted to the signed-in user.

SignInResult​

The result of signIn, createAccount and presentExplicitSignIn. Cancellation is a result, not an error.

FieldTypeDescription
typeSignInResultTypeThe outcome of the flow.
sessionGoogleSession?The signed-in session, set exactly when type is success.

SignInResultType​

type SignInResultType = 'success' | 'cancelled' | 'noSavedCredential'
  • success: the user signed in; session is set.
  • cancelled: the user dismissed the sign-in UI.
  • noSavedCredential: no account has authorized this app yet, or no previous sign-in can be restored.