Reputation: 1485
So far I have set up this:
is CustomCredential -> {
if (credential.type == GoogleIdTokenCredential.TYPE_GOOGLE_ID_TOKEN_CREDENTIAL) {
and it's actually all I need.
But what are the other two possibilities:
is PublicKeyCredential -> {
val responseJson = credential.authenticationResponseJson
}
is PasswordCredential -> {
// Send ID and password to your server to validate and authenticate.
val username = credential.id
val password = credential.password
}
?
When I test the login, I don't see anything that I could do to enable/use those.
This is the request:
val googleIdOption: GetGoogleIdOption = GetGoogleIdOption.Builder()
.setFilterByAuthorizedAccounts(false)
.setServerClientId("keyyyy")
.setNonce(hashedNonce)
.build()
val request: GetCredentialRequest = GetCredentialRequest.Builder()
.addCredentialOption(googleIdOption)
.build()
Do I need to add something to the request to enable those?
The google docs are unclear since they are as always like a puzzle in which all informations are scattered on 1000 different pages.
Upvotes: 1
Views: 141
Reputation: 1
The key is about these codes:
val request: GetCredentialRequest = GetCredentialRequest.Builder()
.addCredentialOption(googleIdOption)
.build()
you only add one CredentialOption with this function addCredentialOption(), which is googleIdOption. The abstract class CredentialOption has several implements: GetPasswordOption, GetPublicKeyCredentialOption, GetGoogleIdOption etc. So if you do not add other credentialOption to the request, the result.credential will be neigther PublicKeyCredential nor PasswordCredential. And GoogleIdTokenCredential extends CustomCredential, so you can only check this branch.
Upvotes: 0