Sign in a consumer
Guides

Sign in a consumer

Choose the mode that matches your app. Both end with a session stored in the SDK. Concepts are in Consumer sessions.

Option A: hosted login

Use this when Wollette's hosted page should authenticate the user.

Configure loginBaseUrl and redirectUri in WolletteConfig.

Register the redirect. Android: intent filter on com.wollette.LoginRedirectActivity (see the Android quickstart). iOS: add the scheme to CFBundleURLTypes.

Call login.

try {
    sdk.login(activity)
} catch (e: WolletteException) {
    when (e.kind) {
        WolletteErrorKind.CANCELLED -> showSignInCancelled()
        else -> showError(e)
    }
}

The SDK opens the page, exchanges the callback for tokens, stores the session and returns. Tokens never reach your code. For an SDK-managed session, it can refresh once after an authentication 401. The specific PIS insufficient-funds business rejection is handled separately.

If your own Android activity receives the redirect, forward it:

Kotlin
override fun onNewIntent(intent: Intent) {
    super.onNewIntent(intent)
    WolletteSdk.completeLogin(intent.data)
}

Option B: your own sign-in

Use this when your backend already authenticates the user with Wollette and holds a consumer access token.

Configure WolletteConfig without loginBaseUrl or redirectUri.

Call applySession with the token, its authorisation ID and its remaining lifetime at the time of the call.

sdk.applySession(
    accessToken = token,
    authorizationId = authorizationId,
    expirySeconds = remainingLifetimeSeconds,
)
  • Map BFF accessToken, id and remaining expiry into this call. Use the host-managed grant instructions; your access pack approves the origin, scopes and callback.
  • Blank inputs or a non-positive lifetime produce VALIDATION; a malformed JWT produces INVALID_RESPONSE; disallowed consumer/delegation claims produce UNAUTHORIZED.
  • Your app owns renewal for every applySession session, even when a login URL is configured. Call applySession again with a renewed token. See Consumer sessions.
  • Applying a session for a different consumer clears the previous consumer's form/recovery state and native payment keys. On iOS, stop the separate Bluetooth client before switching. Handle cleanup failures; hosted login may already have stored its new session before key cleanup.

After sign-in

Choose the next step for the feature you are building:

GoalNext action
Read an existing BaaS walletCall wollette.retrieve with the current consumer session and developer proof. Firebase and device association are not required.
Use push or payment-device featuresCall setRegistrationToken(fcmToken, provider) after sign-in and on token rotation. This association is required for those features, including iOS Bluetooth preparation. See device association.
Start or resume activationCheck walletOnboarding.pendingProgress first, then general progress when no saved operation remains. Follow Resume activation after a restart.

A BaaS account can exist before PIS is complete. A successful wallet read does not confirm activation. Check activation status before features that require completed activation.

Switching accounts

Wait for the current sign-in action to finish before starting another. A successful new session replaces the old one; protected in-flight work for the old session fails with VALIDATION. Android serialises login and clear, while iOS can invalidate a pending login. See Sign out and switch consumers.