signInWithGoogle

abstract suspend fun signInWithGoogle(activity: Activity): AuthUser

Signs in an existing user with their Google account using Google Sign-In.

This method initiates the Google Sign-In flow, allowing users to authenticate using their Google account. The Google ID token is then used to authenticate with Firebase.

Process

  1. Shows Google account picker UI

  2. User selects a Google account

  3. Retrieves Google ID token

  4. Authenticates with Firebase using the Google credential

  5. Returns the authenticated user

Requirements

  • Requires an Activity context for showing the Google Sign-In UI

  • Google Sign-In must be enabled in Firebase Console

  • SHA-1 certificate fingerprint must be configured in Firebase

  • google-services.json must be properly configured

  • Network connectivity is required

Exceptions

  • CancellationException - User cancelled the Google Sign-In flow

  • ApiException - Google Sign-In API errors (invalid configuration, etc.)

  • FirebaseAuthException - Firebase authentication with Google credential failed

  • FirebaseNetworkException - Network connectivity issues

Example

// In your login ViewModel
fun signInWithGoogle() {
_uiState.updateStateWith {
authRepository.signInWithGoogle(activity)
}
}

Return

The authenticated AuthUser upon successful sign-in

Parameters

activity

The activity instance required for showing the Google Sign-In UI

Throws

CancellationException

if user cancels the operation

for Google Sign-In or Firebase authentication failures