Srasti Verma
Srasti Verma

Reputation: 174

flutter passkeys RP ID cannot be validated

I am running fluter passkey's (passkeys 2.1.0) example app but when i enter an email, and try to sign up, it throws the below error.

PlatformException(android-unhandled: androidx.credentials.TYPE_CREATE_PUBLIC_KEY_CREDENTIAL_DOM_EXCEPTION/androidx.credentials.TYPE_DATA_ERROR, [50152] RP ID cannot be validated., [50152] RP ID cannot be validated., null)

android/app/src/main/AndroidManifest.xml file

            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
                <data android:scheme="https" android:host="xyz.org"/>
            </intent-filter>

Also, I am using my own hosted assetlinks json file as well with the same domain name as the RP id. The changes I have made are in flutter-passkeys/packages/passkeys/passkeys/example/lib/auth_service.dart

  Future<void> signupWithPasskey({required String email}) async {
    try {
      final rps1 = rps2 /* rps.startPasskeyRegister(name: email)*/;
      final authenticatorRes = await authenticator2.register(rps1);
      rps.finishPasskeyRegister(response: authenticatorRes);
    } catch (e) {
      log(e.toString());
      rethrow;
    }
  }

final RegisterRequestType rps2 = RegisterRequestType(
  challenge: 'X*******************************I',
  relyingParty: RelyingPartyType(name: 'xyz.org', id: 'xyz.org'),
  user: UserType(
    displayName: 'abc johnson',
    id: base64Url
        .encode('8*******************************0'.codeUnits),
    name: '[email protected]',
  ),
  authSelectionType: authenticatorSelection,
  excludeCredentials: [],
  pubKeyCredParams: pubKeyCredParams,
);

final authenticatorSelection = AuthenticatorSelectionType(
  requireResidentKey: false,
  residentKey: 'required',
  userVerification: 'required',
);

final pubKeyCredParams = [
  PubKeyCredParamType(type: 'public-key', alg: -8),
  PubKeyCredParamType(type: 'public-key', alg: -7),
  PubKeyCredParamType(type: 'public-key', alg: -257),
];

I changed their minSdk from 23 to 28

Upvotes: 1

Views: 102

Answers (0)

Related Questions