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.

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 ConnectController class

Kotlin
import com.otpless.loginpage.main.ConnectController

Declare a connectController member in your SignIn/SignUpActivity

Kotlin
private lateinit var connectController: ConnectController

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

Kotlin
connectController = ConnectController.getInstance(this, OTPLESS_APP_ID, OTPLESS_SECRET)
connectController.initializeOtpless {  }
connectController.registerResponseCallback(this::onAuthResponse)

To enable the logging in debug app, enable it from our Utility class

Kotlin
import com.otpless.loginpage.util.Utility
Utility.isLoggingEnabled = true

Step 3: Starting otpless

Call startOtplessWithLoginPage method from connectController to start otpless login page.

Kotlin
coroutineScope.launch {
    connectController.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.AuthResponse

private fun onAuthResponse(authResponse: AuthResponse) {
    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 connectController.

Kotlin
connectController.closeOtpless()