googlesamples / google-services

A collection of quickstart samples demonstrating the Google APIs for Android and iOS
https://developers.google.com
Apache License 2.0
3.05k stars 2.53k forks source link

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

Open eloisance opened 1 year ago

eloisance commented 1 year ago

Describe your environment

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

nandha2907 commented 11 months ago

@eloisance Did you find any solution for this? facing same issue.