authenticate

abstract suspend fun authenticate(request: IB2BTOTPsAuthenticateParameters): B2BTOTPsAuthenticateResponse

Authenticates a TOTP code from the member's authenticator app, completing the MFA step. Calls the POST /sdk/v1/b2b/totp/authenticate endpoint. Automatically includes the intermediate session token if one is present.

Kotlin:

StytchB2B.totp.authenticate(
B2BTOTPsAuthenticateParameters(
organizationId = "org-test-d5a3b680-e8a3-40c0-b815-ab79986666d0",
memberId = "member-test-d5a3b680-e8a3-40c0-b815-ab79986666d0",
code = "123456",
sessionDurationMinutes = 30,
)
)

iOS:

let params = B2BTOTPsAuthenticateParameters(
organizationId: "org-test-d5a3b680-e8a3-40c0-b815-ab79986666d0",
memberId: "member-test-d5a3b680-e8a3-40c0-b815-ab79986666d0",
code: "123456",
sessionDurationMinutes: 30
)
let response = try await StytchB2B.totp.authenticate(params)

React Native:

StytchB2B.totp.authenticate({
organizationId: "org-test-d5a3b680-e8a3-40c0-b815-ab79986666d0",
memberId: "member-test-d5a3b680-e8a3-40c0-b815-ab79986666d0",
code: "123456",
sessionDurationMinutes: 30,
})

Return

B2BTOTPsAuthenticateResponse containing the authenticated member session.

Parameters

request
  • IB2BTOTPsAuthenticateParameters

  • organizationId — The ID of the organization.

  • memberId — The ID of the member authenticating.

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

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

  • setMfaEnrollment? — Whether to enroll or unenroll the member's MFA method ("enroll" or "unenroll").

  • setDefaultMfa? — Whether to set TOTP as the member's default MFA method.

Throws

StytchError

if the code is invalid or expired.

if the coroutine is cancelled.