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.
| Field | Type | Description |
|---|---|---|
webClientId | string | The 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. |
iosClientId | string | The 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. |
requestOfflineAccess | boolean | Requests a one-time serverAuthCode from interactive sign-in and requestScopes. Defaults to false. |
hostedDomain | string | Restricts sign-in to accounts of this Google Workspace domain, such as example.com. Validate the hd claim on your backend as well. |
nonce | string | The nonce embedded in the ID token. A random nonce is generated for each request when omitted. |
scopes | string[] | Full OAuth scope URLs requested at sign-in in addition to openid, email and profile. |
enableAutoSelect | boolean | Lets 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.
| Field | Type | Description |
|---|---|---|
user | GoogleUser | The signed-in account's profile. |
scopes | string[] | The OAuth scopes granted to this app, including openid, email and profile. Check it before calling requestScopes. |
idToken | string | The OpenID Connect ID token (JWT). Verify it on your backend. |
serverAuthCode | string? | 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.
| Field | Type | Description |
|---|---|---|
id | string | The stable Google account ID, the sub claim of the ID token. Use it as the account key instead of the email. |
email | string? | The account's email address, absent when the email scope was not granted. |
name | string? | The full display name. |
givenName | string? | The given (first) name. |
familyName | string? | The family (last) name. |
photo | string? | The profile picture URL. |
GoogleTokens
Fresh tokens of the signed-in user, from getTokens.
| Field | Type | Description |
|---|---|---|
idToken | string | The OpenID Connect ID token (JWT). |
accessToken | string | An OAuth access token for the granted scopes. |
AuthorizationResult
Credentials for the scopes granted by requestScopes.
| Field | Type | Description |
|---|---|---|
accessToken | string | An OAuth access token for calling Google APIs from the device. |
serverAuthCode | string? | A one-time OAuth code for your backend, present with requestOfflineAccess. |
scopes | string[] | Every scope now granted to the signed-in user. |
SignInResult
The result of signIn, createAccount and presentExplicitSignIn. Cancellation is a result, not an error.
| Field | Type | Description |
|---|---|---|
type | SignInResultType | The outcome of the flow. |
session | GoogleSession? | The signed-in session, set exactly when type is success. |
SignInResultType
type SignInResultType = 'success' | 'cancelled' | 'noSavedCredential'
success: the user signed in;sessionis 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.