getTokenByPasskey method
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:
authSessionis the auth session received from the challenge response.authResponseis the credential returned bynavigator.credentials.create()/.get()connectionis the name of the database connection configured with passkeys.audiencerelates to the API Identifier you want to reference in your access tokens. See API settings to learn more.scopesdefaults toopenid profile email offline_access. You can override these scopes, butopenidis always requested regardless of this setting.organizationIdis 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,
),
);