Introduction
Welcome to the OTPLESS Headless SDK documentation! This guide will walk you through the steps to integrate our SDK into your Android project, providing you with the flexibility to create custom UI elements for your authentication flows.
Requirements
- The compileSdk version should be 35.
- The minimum SDK version supported by the SDK is 21.
- The kotlin version should be 1.9.0 and above.
- The gradle version should be 8.3.1 and above.
This is the new Headless authentication SDK that is significantly faster and more robust than the previous version. This upgrade enhances performance, reliability, and security, ensuring a seamless authentication experience, along with a seamless integration process. We strongly recommend migrating to the new SDK for improved efficiency and better support. To migrate from the old SDK, remove the previous SDK dependency and integration and follow the below mentioned steps.
Step 1: Add SDK Dependency
First, let’s add the OTPLESS SDK to your project. Update your app’s build.gradle
file by adding the following dependency:
Please check the latest version of the SDK here. Make sure to synchronize your Gradle project to fetch the dependency.
Step 2: Update AndroidManifest.xml
Add this intent filter to your LoginActivity in AndroidManifest.xml
:
Replace YOUR_APP_ID
with your actual App
ID provided in
your OTPLESS dashboard.
🔍 Example: If your App ID is “AcmeApp123”, scheme becomes
otpless.acmeapp123
Additionally, ensure your activity is set to singleTop
launch mode and that the exported
attribute is true:
Step 3: Add SDK Initialization
Import OtplessSDK
in your LoginActivity.kt
file:
initialize the SDK in your LoginActivity
or LoginFragment
depending upon your application architecture.
In case of:
- LoginActivity - Initialise the SDK in the
onCreate()
function - LoginFragment - Initialise the SDK in the
onViewCreated()
function.
Replace YOUR_APP_ID
with your actual App
ID provided in
your OTPLESS dashboard.
Step 4: Handle Callback
Now, let’s implement a callback method to handle the response from the OTPLESS SDK:
Override onNewIntent()
ResponseType | Description |
---|---|
INITIATE | When authentication is initiated. |
VERIFY | Triggered when OTP or deeplink verification fails. |
ONETAP | This is the final response of an authentication session. It includes the token that should be sent to your backend for server-to-server validation. |
OTP_AUTO_READ | When the OTP is automatically retrieved from SMS or WhatsApp. It includes OTP value in this responseType |
Error Codes
Checkout error codes here
Step 5: Initiate Authentication
Well done! You have completed the foundational setup of the SDK. Now, let’s move to the next step and understand how to initiate and verify different authentication modes.
Choose the authentication mode you want to integrate from the options below:
OTP
Send a One-Time Password (OTP) via SMS, WhatsApp, or Email for secure user verification.
Magic Link
Provide a seamless login experience by sending an authentication link through SMS, WhatsApp, or Email.
Social Auth
Authenticate users through popular social applications like WhatsApp, Google, Apple, and GitHub.
Was this page helpful?