Requirements

  • The compileSdk version should be 35.
  • The minimum SDK version supported by the SDK is 21.

Step 1: Add SDK Dependency

Add the following dependency in your app’s build.gradle.

  implementation ("io.github.otpless-tech:otpless-loginpage-android:latest_version")

Please check the latest version of the otpless-loginpage-android.

Step 2: Configure your SignIn/SignUp Activity

Import the OtplessController class

Kotlin
import com.otpless.loginpage.main.OtplessController
import com.otpless.loginpage.model.CctSupportConfig
import com.otpless.loginpage.model.CctSupportType

Declare a otplessController member in your SignIn/SignUpActivity

Kotlin
private lateinit var otplessController: OtplessController

Assign the member in onCreate of your SignIn/SignUpActivity, initialize the otplessController and register the callback response method. On initialization is success callback is given in callback method.

Kotlin
otplessController = OtplessController.getInstance(this)
connectController.initializeOtpless(OTPLESS_APP_ID, CctSupportConfig(type = CctSupportType.Cct)) { trackId ->
            // save it for further tracking of journey
}
otplessController.registerResultCallback(this::onAuthResponse)

Step 3: Starting otpless

Call startOtplessWithLoginPage method from otplessController to start otpless login page.

Kotlin
coroutineScope.launch {
    // Prepare query parameters map for login (optional)
    otplessController.startOtplessWithLoginPage()
}
// show progress screen

Step 4: Handle auth response

Extract token from authResponse and validate token with backend apis. Backend documentation

Kotlin
import com.otpless.loginpage.model.OtplessResult

private fun onAuthResponse(authResponse: OtplessResult) {
    val token = authResponse.response.optString("token")
    // validate token with backend
}

Step 5: Closing otpless

When your login page is closed or login is successful, close the otplessController.

Kotlin
otplessController.closeOtpless()