Overview
This guide shows how to implement email OTP authentication using the Turnkey Kotlin SDK. We’ll trigger an OTP to a user’s email address and verify the 6-digit code. Before you being:- Ensure you’ve completed the provider setup from Getting Started and enabled the Auth Proxy with Email OTP in the Turnkey Dashboard.
- In your Turnkey SDK initialization, make sure
authConfig.methods.emailOtpAuthEnabledis set to true (or enabled via dashboard). See Getting Started for the full provider example.
Request an OTP (email)
Create or update your login screen to request an email OTP usinginitOtp. The snippet below demonstrates how to trigger the OTP and verify the 6-digit code to log in.
For a full flow example, see the Kotlin SDK Example App
Verify the OTP code
To verify the OTP code entered by the user, use theloginOrSignUpWithOtp function with the otpId, otpCode, and contact email.
This will automatically log in or sign up the user based on whether they already own an existing sub-org.
Notes
- Default OTP length is 6; if you’ve customized OTP in the dashboard, validate accordingly.
- If you need to resend a code, you can call
initOtpagain with the same email.