Quick Start — the ready-made button

Drop in the Paspo ID sign-in button and wire up two callbacks.

The ready-made button runs the entire flow on tap and blocks repeated taps while a request is in progress. It requires two inputs: a nonce provider and a result handler.

The examples below reference the following functions that you provide:

  • backend.requestSsoNonce(): String — a suspend call that requests a fresh one-time nonce from your server.
  • backend.signInWithPaspo(authCode: String) — sends the authorization code to your server to complete sign-in.
  • showError(error: PaspoClientError) — your error presentation.
  • onPaspoResult(result: PaspoAuthResult) — a single result handler, defined once:
private fun onPaspoResult(result: PaspoAuthResult) {
    when (result) {
        is PaspoAuthResult.Success -> backend.signInWithPaspo(result.authCode)
        is PaspoAuthResult.Failure -> showError(result.error)
        PaspoAuthResult.Cancelled,
        PaspoAuthResult.NotInstalled -> Unit
    }
}

Compose

PaspoSignInButton(
    nonceProvider = backend::requestSsoNonce,
    onResult = ::onPaspoResult,
)

By default, the button is filled with the Paspo brand color. It can be styled to match your application:

PaspoSignInButton(
    nonceProvider = backend::requestSsoNonce,
    onResult = ::onPaspoResult,
    theme = PaspoButtonTheme.LIGHT,   // BRAND (default), LIGHT, DARK, NEUTRAL
    cornerRadius = 12.dp,             // the default renders a pill
)

Classic Views

Declare the button in the layout:

<paspo.id.ssoprovider.ui.PaspoSignInButton
    android:id="@+id/paspo_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:paspoTheme="light"
    app:paspoCornerRadius="12dp" />

and bind the flow once:

binding.paspoButton.setAuthHandler(
    activity = this,
    scope = PaspoScope.PHONES,
    nonceProvider = backend::requestSsoNonce,
    onResult = ::onPaspoResult,
)

The button renders independently of the host theme so that it appears identical across applications. If nonceProvider throws, the result is Failure(SERVICE_UNAVAILABLE). The Compose module additionally exposes a render-only PaspoSignInButtonContent(colors = PaspoButtonColors(...)) that reports clicks without running the flow, for full visual control.

Button options

OptionValuesDefault
theme / app:paspoThemeBRAND, LIGHT, DARK, NEUTRALBRAND
cornerRadius / app:paspoCornerRadiusany dimension; a large value renders a pillpill
iconOnly / app:paspoIconOnlytrue / false (logo only)false
showLogo / app:paspoShowLogotrue / false (text only when false)true

Need full control over the UI instead? See Custom integration.