Q:

Get Google signed user information

I have an app that get Google credentials in order to register user into my API. I need the idToken provided by the Google flow.
Following this tutorial, I was able to sign in.
Then, I have a splash screen. I want it to verify if the user is already allowed by Google, to go to the main activity. If not, go to the login activity.
But according to the tutorial's code, it is asking Firebase using the code below, which provides me, of course, a Firebase token, not the Google one.
override fun onStart() {
    super.onStart()
    val user = FirebaseAuth.getInstance().currentUser
    if (user != null) {
        startActivity(MainActivity.getLaunchIntent(this))
        finish()
    }
}

So, the question is: how can I get the Google information to retrieve the token, so my API can validate if the token?

A:

If someone else need to implements something alike, I'll share how I did it.
There is a silentSignIn from Google SDK which allows to do it.
So, this is the code:
val signInOptions = getSignInOptions(this)
val googleSignInClient = GoogleSignIn.getClient(this, signInOptions)
googleSignInClient.silentSignIn().addOnCompleteListener {
    val account: GoogleSignInAccount? = it.result
    if (account != null) {
        // success
    }
    else {
        // failure
    }
}

