Skip to main content
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.

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: Installation

Add the following to your pubspec.yaml:
Then, run:
Please find the latest version of the SDK here.

Step 2: Platform-specific Integrations

  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. If your MainActivity extends FlutterActivity, change it to extend FlutterFragmentActivity for lifecycle awareness.

Step 3: Initialize the SDK

  1. Import the SDK in your main.dart file:
  1. Then, create an instance of the SDK:
  1. In your LoginScreen’s initState, initialize the SDK and set the response callback:
LoginScreen
  1. Create a callback function to handle the response:
LoginScreen

Response Objects Structure

Step 4: Initiate Authentication

Initiate the authentication process based on the user’s selected method.
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.