Assigned
Status Update
Comments
bl...@google.com <bl...@google.com> #2
Automated by Blunderbuss job android-credential-manager-autoassigner for config android_credman_config for component 1301097.
jb...@google.com <jb...@google.com>
ak...@google.com <ak...@google.com> #3
The error you posted state "activity is cancelled by the user". This implies the request was cancelled somehow during the request.
Can you grab a bugreport and attach it to this bug?
Description
How to test: open your email, change your name and last name, and click save. And call this "fetch" function.
Android, kotlin.
private fun fetch() {
scope.launch {
val credentialManager = CredentialManager.create(context)
try {
val result = credentialManager.getCredential(
request = request,
context = context,
)
handleSignIn(result)
} catch (e: GetCredentialException) {
handleFailure(e)
}
}
}
----
private fun handleSignIn(result: GetCredentialResponse) {
// Handle the successfully returned credential.
when (val credential = result.credential) {
is CustomCredential -> {
if (credential.type == GoogleIdTokenCredential.TYPE_GOOGLE_ID_TOKEN_CREDENTIAL) {
try {
val googleIdTokenCredential = GoogleIdTokenCredential.createFrom(credential.data)
googleIdTokenCredential.idToken
googleIdTokenCredential.displayName
} catch (e: GoogleIdTokenParsingException) {
e.message
}
}
} ......
private val googleIdOption: GetGoogleIdOption = GetGoogleIdOption.Builder()
.setFilterByAuthorizedAccounts(false)
.setServerClientId(....ID.....)
.setAutoSelectEnabled(false)
.build()
private val request: GetCredentialRequest = GetCredentialRequest.Builder()
.addCredentialOption(googleIdOption)
.setPreferIdentityDocUi(false)
.setPreferImmediatelyAvailableCredentials(false)
.build()