authenticate

abstract suspend fun authenticate(parameters: BiometricsParameters): BiometricsAuthenticateResponse

Authenticates the user using a previously registered biometric credential. Performs a two-step flow: calls POST /sdk/v1/biometrics/authenticate/start to get a challenge, prompts the user for biometric authentication, then calls POST /sdk/v1/biometrics/authenticate to complete.

Kotlin (Android):

StytchConsumer.biometrics.authenticate(
BiometricsParameters(
context = activity,
sessionDurationMinutes = 30,
)
)

iOS:

let params = BiometricsParameters(sessionDurationMinutes: 30)
let response = try await StytchConsumer.biometrics.authenticate(params)

React Native:

StytchConsumer.biometrics.authenticate({ sessionDurationMinutes: 30 })

Return

BiometricsAuthenticateResponse containing the authenticated session and user.

Parameters

parameters
  • BiometricsParameters

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

  • (Android only) context — The FragmentActivity used to display the biometric prompt.

  • (Android only) allowDeviceCredentials — Whether to allow PIN/pattern/password as a fallback.

  • (Android only) promptData — Custom title, subtitle, and description for the biometric prompt.

  • (Android only) allowFallbackToCleartext — Whether to store the key in cleartext if the secure enclave is unavailable.

  • (iOS only) promptData — Custom reason string shown in the Face ID / Touch ID prompt.

Throws

if no biometric registration exists on this device.

StytchError

if authentication fails.

if the coroutine is cancelled.