Skip to main content

Overview

OTPless SDK accepts the user’s identity (phone number or email), authenticates through multiple channels, and returns a secure token upon success.The merchant app sends this token to its backend, which verifies it with the OTPless Server before proceeding with the user journey. SDK Overview Chart

Integration Steps

Step 1: Install OTPLESS SDK Dependency

To get started, you need to install dependencies for kotlinx-serialization, kotlin-cocoapods and Otpless Android & iOS dependencies. You can do this by adding following the below mentioned steps:

Adding dependencies in gradle files:

Add the kotlinx-serialization dependency in your libs.versions.toml file:
In your project level build.gradle.kts file, add the following code:
In your build.gradle.kts(:composeApp) file, add the following code:
Adding Otpless SDK dependencies and kotlinx-serialization in your build.gradle.kts(:composeApp) file:

Adding dependencies in Podfile:

Navigate to your iosApp directory and initialize the Podfile (if not done already) by running the following command:
This will create a Podfile in the iosApp directory. Open the Podfile and add the following lines:
After adding the above lines, run the following command to install the dependencies:
Once all the dependencies are added, sync the gradle and run pod install to install the iOS app dependency.

Step 2: Platform specific integration

  1. Add intent filter inside your android/app/src/main/AndroidManifest.xml file into your Main activity code block:
    This step is only needed for Magic Link. Smart Auth integration do not require this step.
Replace YOUR_APP_ID with your actual App ID provided in your OTPLESS dashboard.
  1. Add Network Security Config inside your android/app/src/main/AndroidManifest.xml file into your <application> code block (Only required if you are using the SNA feature):
  1. Change your activity launchMode to singleTop and exported true for your Main Activity:
    This step is only needed for Magic Link. Smart Auth integration do not require this step.
  1. In your MainActivity.kt file, add the following code to handle deeplinks:
    This step is only needed for Magic Link. Smart Auth integration do not require this step.

Step 3: Create expect function declarations in commonMain

In your commonMain source set, create a new file named OtplessAuthHandler.kt and add the following code:

Step 4: Implement expect function declarations in androidMain and iosMain

Step 5: Initialize the Otpless SDK

In your LoginScreen.kt file, initialize the Otpless SDK. Make sure to initialize the SDK in DisposableEffect block to free the resources consumed by Otpless once your LoginScreen.kt is destroyed.
To handle the Otpless response, create a function named handleOtplessResponse in your LoginScreen.kt file. This function will handle the response received from the Otpless SDK.

Response Objects Structure

Step 6: Start the Otpless SDK

In your LoginScreen.kt file, start the Otpless SDK by calling the start function with the required parameters.
Phone authentication allows users to verify their identity using their phone number. Merchants can choose from various authentication methods:
  • Silent Authentication (SNA) – Automatically verifies the user without requiring OTP or MAGICLINK.
  • OTP on Desired Channel – Sends a one-time password (OTP) via SMS, WhatsApp, or another preferred channel.
  • Magic Link – Sends a link that users can click to authenticate.
  • SNA + OTP – Uses silent authentication first and falls back to OTP if needed.
  • OTP + Magic Link – Sends both an OTP and a magic link, allowing users to authenticate via either method.

Verify OTP

To verify the OTP entered by the user, use the verify method with the necessary parameters. Verifying OTP is required only in case of OTP authentication. No need to verify OTP in case of MAGICLINK.

Error Handling

The error codes for android and iOS have to be handled separately.