google-services icon indicating copy to clipboard operation
google-services copied to clipboard

Google sign in - silentSignIn is failing (SIGN_IN_REQUIRED / INTERNAL_ERROR)

Open eloisance opened this issue 1 year ago • 1 comments

Describe your environment

  • Device: Multiples (Samsung, Google, Huawei, Xiaomi...)
  • OS version: Multiples (12, 11, 10, 9..)
  • SDK version: 33
  • [Android] Google Play Services version: 20.2.0

Describe the problem:

Steps to reproduce:

Couldn't reproduce.

Observed Results:

For some of our users, the silentSignIn method is failing with the error code SIGN_IN_REQUIRED or INTERNAL_ERROR during our auto-login process when starting the app (Splash screen), hence we are not able to send to our backend a valid token.

This past month we had 2k of SIGN_IN_REQUIRED and 3k of INTERNAL_ERROR non-fatals coming from our production users. So far we are not able to reproduce it, neither understand in which scenario it can happen.

Screenshot 2022-11-14 at 15 29 02

Expected Results:

To always received the idToken, existing one if still valid or a new one if expired.

Relevant Code:

How we are trying to get a fresh token during the auto-login process :

val googleSignOptions: GoogleSignInOptions = Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
        .requestIdToken(serverClientId)
        .requestEmail()
        .build()
val googleSignInClient = GoogleSignIn.getClient(safeActivity, googleSignInOptions)
googleSignInClient.silentSignIn().addOnCompleteListener { task ->
    try {
        val account: GoogleSignInAccount? = task.getResult(ApiException::class.java)
        account?.idToken?.let { idToken ->
            // return success with the idToken
        }
    } catch (exception: ApiException) {
        // return the exception
    }
}

This is affecting badly the user experience as those users needs to sign-in again inside the app. Can you share which workflow we should use to improve this experience for our end users ?

Thanks

eloisance avatar Nov 14 '22 14:11 eloisance