authenticate

abstract suspend fun authenticate(parameters: PasskeysParameters): WebAuthnAuthenticateResponse

Authenticates the user with an existing registered passkey. Performs a two-step flow: calls POST /sdk/v1/webauthn/authenticate/start/primary (no session) or POST /sdk/v1/webauthn/authenticate/start/secondary (with session) to get assertion options, invokes the platform credential API, then calls POST /sdk/v1/webauthn/authenticate to complete.

Kotlin (Android):

StytchConsumer.passkeys.authenticate(
PasskeysParameters(
activity = activity,
domain = "example.com",
sessionDurationMinutes = 30,
)
)

iOS:

let params = PasskeysParameters(domain: "example.com", sessionDurationMinutes: 30)
let response = try await StytchConsumer.passkeys.authenticate(params)

React Native:

StytchConsumer.passkeys.authenticate({ domain: "example.com", sessionDurationMinutes: 30 })

Return

WebAuthnAuthenticateResponse containing the authenticated session and user.

Parameters

parameters
  • PasskeysParameters

  • domain — The relying party domain (e.g. "example.com").

  • sessionDurationMinutes? — Duration of the session to create, in minutes.

  • preferImmediatelyAvailableCredentials — Whether to prefer credentials that are immediately available on this device.

  • (Android only) activity — The Activity used to present the credential selection dialog.

Throws

PasskeysUnsupportedError

if passkeys are not supported on the current platform.

StytchError

if authentication fails.

if the coroutine is cancelled.