getTokenByPasskey method

Future<Credentials> getTokenByPasskey({
  1. required String authSession,
  2. required dynamic authResponse,
  3. String? connection,
  4. String? audience,
  5. Set<String> scopes = const {'openid', 'profile', 'email', 'offline_access'},
  6. String? organizationId,
})

Exchanges a passkey credential response for Auth0 tokens.

This is the final step of both the passkey login and signup flows. Call this after the browser's WebAuthn API (navigator.credentials.create()/.get()) returns the credential (from either passkeySignupChallenge or passkeyLoginChallenge).

Parameters:

  • authSession is the auth session received from the challenge response.
  • authResponse is the credential returned by navigator.credentials.create()/.get()
  • connection is the name of the database connection configured with passkeys.
  • audience relates to the API Identifier you want to reference in your access tokens. See API settings to learn more.
  • scopes defaults to openid profile email offline_access. You can override these scopes, but openid is always requested regardless of this setting.
  • organizationId is the optional Auth0 organization to authenticate with.

Usage example

final challenge = await auth0Web.passkeyLoginChallenge(
  connection: 'Username-Password-Authentication',
);

final credential = await navigator.credentials.get(
  CredentialRequestOptions(
    publicKey: challenge.authParamsPublicKey
        as PublicKeyCredentialRequestOptions,
  ),
);

final credentials = await auth0Web.getTokenByPasskey(
  authSession: challenge.authSession,
  authResponse: credential,
  connection: 'Username-Password-Authentication',
);

Implementation

Future<Credentials> getTokenByPasskey({
  required final String authSession,
  required final dynamic authResponse,
  final String? connection,
  final String? audience,
  final Set<String> scopes = const {
    'openid',
    'profile',
    'email',
    'offline_access'
  },
  final String? organizationId,
}) =>
    Auth0FlutterWebPlatform.instance.getTokenByPasskey(
      WebGetTokenByPasskeyOptions(
        authSession: authSession,
        authResponse: authResponse,
        connection: connection,
        audience: audience,
        scopes: scopes,
        organization: organizationId,
      ),
    );