Skip to content

Pre-selecting specific passkeys using the allowCredentials property

If the user is already logged into their account, or they have presented a username/email in a two-step login flow, you can help them out by preselecting the passkey they should use to authenticate.

frontend/login.ts
import { authenticatePasskey } from "@passlock/client";
// from your backend
const allowCredentials = [existingPasskeyId]
const result = await authenticatePasskey({ allowCredentials, ... })

Given that you already know their user ID (or claimed ID), you can look up the passkeys associated with the account and pass them to authenticatePasskey via the allowCredentials property.

This is conceptually similar to the excludeCredentials registration option.

You can end up with a scenario in which a user has deleted a passkey locally but it’s still linked in your backend system. When you pass the missing passkey id via allowCredentials the user’s device will adopt the roaming authenticator flow, assuming the passkey exisits on a different device. See handling missing passkeys.