Skip to content

Instantly share code, notes, and snippets.

@dllewellyn
Created July 2, 2020 08:01
Show Gist options
  • Save dllewellyn/d2bc0822ef6e9d23457eb6ef75ede748 to your computer and use it in GitHub Desktop.
Save dllewellyn/d2bc0822ef6e9d23457eb6ef75ede748 to your computer and use it in GitHub Desktop.
private val loginResult =
registerForActivityResult(ActivityResultContracts.StartIntentSenderForResult()) {
val credential = oneTapClient.getSignInCredentialFromIntent(it.data)
val idToken = credential.googleIdToken
val username = credential.id
val password = credential.password
when {
idToken != null -> {
// Got an ID token from Google. Use it to authenticate
// with your backend.
Log.d(TAG, "Got ID token.")
}
password != null -> {
// Got a saved username and password. Use them to authenticate
// with your backend.
Log.d(TAG, "Got password.")
}
else -> {
// Shouldn't happen.
Log.d(TAG, "No ID token or password!")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment