Android - got "NoCredentialException" when calling "getCredentialAsync()" of androidx credential manager PASSKEYS

380 views Asked by At

I am developing an app that wanted to integrate passkeys. I followed the tutorial from https://developer.android.com/training/sign-in/passkeys

Which before signing in we should register our passkeys first. To do that, I am calling createCredentialAsync() method first:

public void startRegistration(PluginCall call) {
    String requestJson = call.getData().toString();
    String clientDataHash = null;

    CreatePublicKeyCredentialRequest createPublicKeyCredentialRequest =
      new CreatePublicKeyCredentialRequest(requestJson, clientDataHash, true);

    CancellationSignal cancellationSignal = null;

    implementation.getCredentialManager().createCredentialAsync(
      createPublicKeyCredentialRequest,
      getActivity(),
      cancellationSignal,
      getContext().getMainExecutor(),
      new CredentialManagerCallback<CreateCredentialResponse, CreateCredentialException>() {
        @Override
        public void onResult(CreateCredentialResponse result) {
          Log.d("SUCCESS CREATE PASSKEY", result.getType());
        }

        @Override
        public void onError(CreateCredentialException e) {
          JSObject ret = new JSObject();
          ret.put(type, e.getMessage());
          call.reject(type,ret);
        }
      });
  }

This process is success. I can show the biometric pop up and register the passkey to my server.

But now, when I want to authenticate using getCredentialAsync(), it gave me "NoCredentialException"

Does anyone have any idea on solving this? Thank you

0

There are 0 answers