Open the Human Token capture natively in your Android app using only the webAppToken of the process.
The SDK Lite is the Unico Android SDK for the Human Token. It runs the capture in the Unico web experience embedded in the SDK and enters only with the webAppToken of a process created by your backend. The app holds no credentials: everything it needs comes from the token.
Available from Android SDK 6.14.0 onwards, as the io.unico:capture-lite artifact.
How it works
Prerequisites
| Requirement | Version / value |
|---|---|
| Minimum Android | 5.0 (API 21) |
| Kotlin | 1.8.22 or later |
| Java compatibility | JavaVersion.VERSION_1_8 |
| Android Gradle Plugin (AGP) | 8.6.0 or later |
| Android Studio | Koala Feature Drop (2024.1.2) or later |
| Required permissions | INTERNET, CAMERA |
- A backend that creates the process with Create Process and hands the
webAppTokenfrom the response to the app. - Token entry enabled for your account by Unico in the target environment.
Step 1: Add the dependency
The SDK Lite is distributed through the Unico Maven repository. Add the repository to the dependencyResolutionManagement block of your settings file, then add io.unico:capture-lite to the module-level build file:
- Kotlin DSL
- Groovy
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven("https://maven-sdk.unico.run/sdk-mobile")
}
}
dependencies {
implementation("io.unico:capture-lite:<version>")
}
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven { url "https://maven-sdk.unico.run/sdk-mobile" }
}
}
dependencies {
implementation 'io.unico:capture-lite:<version>'
}
Step 2: Get the webAppToken from your backend
Your backend creates the process with Create Process and sends the app the webAppToken field of the response. The app passes it to the SDK as is. The token and link fields of the same response are for other uses: passed to the SDK, the token is rejected with error 73304.
- One process per journey. Create a new process, and a new token, every time the user starts the capture.
- Short-lived. The
webAppTokenis valid for 5 minutes. Create it right before opening the capture. - Same environment. The process and the SDK must use the same environment (UAT or PROD).
Never embed credentials, access keys or a fixed token in the app. The webAppToken is created by your backend for each journey.
Step 3: Open the capture
Get the webAppToken from your backend, build the SDK with AcessoBio, set the environment and call prepareAndOpenCamera(webAppToken, listener) with it. The call prepares the SDK and opens the capture at once.
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import com.acesso.acessobio_android.AcessoBioListener
import com.acesso.acessobio_android.iAcessoBioSelfie
import com.acesso.acessobio_android.onboarding.AcessoBio
import com.acesso.acessobio_android.onboarding.models.Environment
import com.acesso.acessobio_android.services.dto.ErrorBio
import com.acesso.acessobio_android.services.dto.ResultCamera
import com.acesso.acessobio_android.services.dto.SuccessResult
import kotlinx.coroutines.launch
class CaptureActivity : AppCompatActivity() {
// Same environment used by your backend to create the process
private val environment = Environment.PROD
private val callback = object : AcessoBioListener {
override fun onErrorAcessoBio(errorBio: ErrorBio?) { }
override fun onUserClosedCameraManually() { }
override fun onSystemClosedCameraTimeoutSession() { }
override fun onSystemChangedTypeCameraTimeoutFaceInference() { }
}
private val selfieListener = object : iAcessoBioSelfie {
// Journey result. Required.
override fun onSuccess(successResult: SuccessResult) {
// Journey completed: send successResult.processId to your backend
}
// Required by the interface. The journey result arrives in onSuccess.
override fun onSuccessSelfie(result: ResultCamera) { }
override fun onErrorSelfie(errorBio: ErrorBio) {
// 73305 (expired token): create a new process and try again
}
}
fun startCapture() {
lifecycleScope.launch {
// Your backend calls Create Process and returns the `webAppToken` field of the response
val webAppToken = yourBackend.createHumanTokenProcess()
val camera = AcessoBio(this@CaptureActivity, callback)
.setEnvironment(environment)
.build()
camera.prepareAndOpenCamera(webAppToken, selfieListener)
}
}
}
onSuccess is requirediAcessoBioSelfie declares onSuccess with a default implementation, so the compiler does not require it. Without an override, the capture does not open and onErrorSelfie receives error 74001.
- Prepare errors (rejected or expired token) and capture errors arrive in
onErrorSelfie. - The capture does not run on emulators (error
73006). onSuccesssignals that the journey ended, not that the user was approved. Always read the result with Get Process or a webhook.
Environment
The capture uses the environment set by setEnvironment on the builder. Use the environment where the process was created.
Error codes
| Code | When | What to do |
|---|---|---|
73006 | Running on an emulator | Test on a physical device |
73304 | The webAppToken is blank or was rejected (invalid signature or content), including when the token field is passed instead | Pass the webAppToken of a valid process |
73305 | The token expired | Create a new process and call prepareAndOpenCamera again with the new webAppToken |
73701 | The call is not available in the SDK Lite | Use prepareAndOpenCamera(webAppToken, listener) |
74001 | The listener does not override onSuccess | Override onSuccess(successResult: SuccessResult) |
What's next
- Fetch the result with Get Process and store
data.humanToken.valuewith the user record. - Can't use the SDK Lite? Open the journey
linkinstead, as described in Android. - Check the versions that include the lite edition in the SDK Lite Release Notes.
- Integrating on iOS? See iOS SDK Lite.