LoginWA Android SDK (Kotlin)

Lightweight REST client to start and verify OTP over WhatsApp.

Repo: GitHub · Module: sdk/android · Sample: sdk/android/sample

Install (planned Maven Central)

Add the dependency:

dependencies {
    implementation("com.loginwa:loginwa-otp:0.1.0")
}

Until published, import the sdk/android project as a module or publish to Maven Local.

Initialize

val client = LoginWAClient(
    apiKey = BuildConfig.LOGINWA_API_KEY,
    baseUrl = "https://api.loginwa.com/api/v1", // optional override
    enableLogging = true
)

Start OTP

val start = client.startOtp(
    StartOtpRequest(
        phone = "6281234567890",
        countryCode = "62",
        otpLength = 6,
        messageTemplate = "OTP code {code} valid for {ttl} minutes",
        meta = mapOf("user_id" to "123")
    )
)
val sessionId = start.sessionId

Verify OTP

val verify = client.verifyOtp(
    VerifyOtpRequest(
        sessionId = sessionId.orEmpty(),
        otpCode = "123456"
    )
)
if (verify.status == "verified") {
    // success
}

Errors

Notes

Sample app