I copied the code from the codelab to create and save credentials.
However, I got the below error when calling credentialManager.createCredential(activity, request)
:
[FetchAllowlistedOriginOperation] rejecting asserted origin from app 'com.myapp.test', with fingerprint(s)
13:3A:39:D2:B9:48:1A:2C:B3:A5..., because it is not in the list of trusted browsers. [CONTEXT service_id=68 ]
[createCredential] CreateCredentialException: Credential save error
androidx.credentials.exceptions.CreateCredentialNoCreateOptionException: No create options available.
at androidx.credentials.CredentialProviderFrameworkImpl.convertToJetpackCreateException$credentials_release(CredentialProviderFrameworkImpl.kt:302)
at androidx.credentials.CredentialProviderFrameworkImpl$onCreateCredential$outcome$1.onError(CredentialProviderFrameworkImpl.kt:201)
at androidx.credentials.CredentialProviderFrameworkImpl$onCreateCredential$outcome$1.onError(CredentialProviderFrameworkImpl.kt:187)
at android.credentials.CredentialManager$CreateCredentialTransport.lambda$onError$2(CredentialManager.java:752)
at android.credentials.CredentialManager$CreateCredentialTransport.$r8$lambda$8NwBIrbcK6SvF9Mra_qL_8hhFMU(Unknown Source:0)
at android.credentials.CredentialManager$CreateCredentialTransport$$ExternalSyntheticLambda0.run(Unknown Source:6)
at androidx.credentials.CredentialManager$$ExternalSyntheticLambda0.execute(Unknown Source:0)
at android.credentials.CredentialManager$CreateCredentialTransport.onError(CredentialManager.java:751)
at android.credentials.ICreateCredentialCallback$Stub.onTransact(ICreateCredentialCallback.java:123)
at android.os.Binder.execTransactInternal(Binder.java:1344)
at android.os.Binder.execTransact(Binder.java:1275)
This is my assetlinks.json
:
[
{
"relation": [
"delegate_permission/common.handle_all_urls",
"delegate_permission/common.get_login_creds"
],
"target": {
"namespace": "web",
"site": "https://myapp.test.com"
}
},
{
"relation": [
"delegate_permission/common.handle_all_urls",
"delegate_permission/common.get_login_creds"
],
"target": {
"namespace": "android_app",
"package_name": "com.myapp.test",
"sha256_cert_fingerprints": [
"62:8D:D4:12:94..."
]
}
}
]
I can successfully created a passkey device in Google and created a credential (screen lock) which can be seen in "Password Manager" in "Manage your Google Account" before.
And then I did some changes and tests. And I rolled back my code.
However, createCredential
does not work anymore.
Notice that fingerprint (13:3A:39:D2:B9:48:1A:2C:B3:A5...)
in the error is different from the fingerprint (62:8D:D4:12:94...
) in my assetlinks.json
.
After some tests, I found that I can resolve this error by removing origin parameter when calling
CreatePublicKeyCredentialRequest
to createCreatePublicKeyCredentialRequest
forcreateCredential
.Originally, I used the below code:
And then I used the below code to fix the error:
Now I can get the passkey prompt like this:
However, App cannot show credential selector and got another error: