authenticate

abstract suspend fun authenticate(request: ITOTPsAuthenticateParameters): TOTPsAuthenticateResponse

Authenticates a time-based one-time passcode from the user's authenticator app. Calls the POST /sdk/v1/totps/authenticate endpoint.

Kotlin:

StytchConsumer.totps.authenticate(
TOTPsAuthenticateParameters(totpCode = "123456", sessionDurationMinutes = 30)
)

iOS:

let params = TOTPsAuthenticateParameters(totpCode: "123456", sessionDurationMinutes: 30)
let response = try await StytchConsumer.totps.authenticate(params)

React Native:

StytchConsumer.totps.authenticate({ totpCode: "123456", sessionDurationMinutes: 30 })

Return

TOTPsAuthenticateResponse containing the authenticated session and user.

Parameters

request
  • ITOTPsAuthenticateParameters

  • totpCode — The 6-digit code from the user's authenticator app.

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

Throws

StytchError

if the code is invalid or expired.

if the coroutine is cancelled.