rememberGoogleSignInState

fun rememberGoogleSignInState(filterByAuthorizedAccounts: Boolean = false, isAutoSelectEnabled: Boolean = true, scopes: List<String> = BASIC_AUTH_SCOPE, requestAccessToken: Boolean = false, onResult: (Result<GoogleUser>) -> Unit): SignInState

Google Sign-In (without any backend) as a Compose state holder. Make sure GoogleAuthProvider.create was called at application start.

Parameters are read at launch time: recomposing with new values (e.g. toggling between sign-in and sign-up modes) updates the existing state, and SignInState.launch uses whatever is current when the user taps.

val googleSignIn = rememberGoogleSignInState(onResult = { result ->
result.onSuccess { user -> val idToken = user.idToken } // send to your backend
.onFailure { error -> /* show why sign-in failed */}
})

Button(onClick = { googleSignIn.launch() }) { Text("Google Sign-In") }

Parameters

filterByAuthorizedAccounts

true limits the account list to accounts previously used with this app; false lists all available accounts.

isAutoSelectEnabled

sign in automatically when exactly one eligible account exists.

scopes

OAuth scopes to request. Default listOf("email", "profile").

requestAccessToken

request an OAuth access token alongside the ID token. Only affects Android, where Credential Manager returns an ID token alone and an access token needs a separate authorization request with its own consent prompt; every other platform already returns one. Asking for scopes beyond email/profile implies this. See GoogleUser.accessToken.

onResult

receives a successful Result with the GoogleUser, or a failed Result carrying the reason - the platform credential exception, the user cancelling, or a token parsing failure.