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
}
}
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
)
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.
| Option | Values | Default |
|---|---|---|
theme / app:paspoTheme | BRAND, LIGHT, DARK, NEUTRAL | BRAND |
cornerRadius / app:paspoCornerRadius | any dimension; a large value renders a pill | pill |
iconOnly / app:paspoIconOnly | true / false (logo only) | false |
showLogo / app:paspoShowLogo | true / false (text only when false) | true |
Need full control over the UI instead? See Custom integration.