enrollPasskeyChallenge method

Future<PasskeyEnrollmentChallenge> enrollPasskeyChallenge({
  1. String? userIdentityId,
  2. String? connection,
})

Requests a challenge for enrolling a new passkey. This is the first part of the passkey enrollment flow.

Returns a PasskeyEnrollmentChallenge whose authParamsPublicKey holds the WebAuthn creation options as JSON (base64url-encoded values). Decode it with the browser's PublicKeyCredential.parseCreationOptionsFromJSON(), pass the result to navigator.credentials.create(), then convert the new credential with its toJSON() method and PasskeyCredential.fromMap. Finally, pass the challenge and credential to enrollPasskey.

Note: parseCreationOptionsFromJSON() and toJSON() require Chrome or Edge 129+, Firefox 119+, or Safari 18.4+. navigator.credentials .create() requires a user gesture, so start the flow from a click handler.

Note: Passkey enrollment requires a custom domain: create Auth0Web with it. The challenge's relying party ID is that custom domain, so the passkey can only be created on pages served from it or one of its subdomains; elsewhere the browser throws a SecurityError.

Optionally pass a userIdentityId (needed if the user logged in with a linked account) and/or a database connection name. If a connection name is not specified, your tenant's default directory is used.

Requires an access token with the create:me:authentication_methods scope and audience https://{domain}/me/.

Usage example

final challenge = await myAccount.enrollPasskeyChallenge();
// Create the passkey in the browser with challenge.authParamsPublicKey,
// then call enrollPasskey with the resulting credential.

Implementation

Future<PasskeyEnrollmentChallenge> enrollPasskeyChallenge({
  String? userIdentityId,
  String? connection,
}) =>
    Auth0FlutterWebPlatform.instance
        .enrollPasskeyChallenge(_accessToken, userIdentityId, connection);