Consumer sessions
A session identifies the consumer for protected API calls. The SDK stores it in an encrypted file on Android or Keychain on iOS and supplies the access token to its API client.
Choose who owns renewal
| Session source | Create it with | Who renews it |
|---|---|---|
| Hosted login | login | The SDK uses the configured login service and retries an authentication 401 once with a fresh developer proof. The specific PIS insufficient-funds rejection is handled separately. |
| Your backend | applySession | Your app obtains a renewed consumer token and calls applySession again. The SDK does not refresh this session, even if loginBaseUrl is configured. |
login does not return tokens. With applySession, your app already holds the token and passes it to the SDK.
Hosted login
Configure loginBaseUrl and redirectUri, register the callback scheme, then call:
sdk.login(activity)try await sdk.login()The SDK opens a Chrome Custom Tab on Android or ASWebAuthenticationSession on iOS, exchanges the callback and stores the session. User dismissal throws CANCELLED / .cancelled. Cancelling the Swift task throws CancellationError instead.
Android receives the redirect through LoginRedirectActivity. If your own activity receives it, forward the URI to WolletteSdk.completeLogin(uri).
Apply a session from your backend
sdk.applySession(accessToken, authorizationId, expirySeconds)try await sdk.applySession(
accessToken: accessToken,
authorizationId: authorizationId,
expirySeconds: expirySeconds
)expirySeconds is the token's remaining lifetime when you call applySession. The SDK calculates expiry as the current time plus that duration. Do not pass the token's original lifetime after some of it has elapsed.
| Failure | Error |
|---|---|
| Blank token or authorisation ID; non-positive lifetime | VALIDATION |
| Malformed JWT structure or unreadable payload | INVALID_RESPONSE |
| Decoded token is not a permitted CONSUMER token, including disallowed delegation claims | UNAUTHORIZED |
The local parser reads and checks claims; it does not verify the JWT's cryptographic signature. Obtain the token from your trusted backend integration.
Use the existing BFF grant to obtain these values. Your access pack must approve the environment, client/scopes and callback.
Required input sources
| Value | Obtain it from | Avoid |
|---|---|---|
accessToken | Approved consumer authentication integration | A merchant token or an untrusted client-supplied token |
authorizationId | The BFF grant response id | Inventing it or substituting DeveloperId/consumer ID |
expirySeconds | The token's remaining lifetime at this call | Reusing its original lifetime after time has elapsed |
The mobile SDK accepts these values; it does not define your backend's sign-in endpoint or issue an authorisation ID. Hosted login is the quickstart path once Wollette has approved its origins and callback.
Upgrading older stored sessions
Sessions written before the ownership marker was added are treated as legacy sessions. With a login service configured, the SDK may refresh them. Apply a fresh host-supplied session to mark it as host-managed when migrating an integration that owns renewal.
Obtain a host-managed grant
For applySession, use your approved BFF authentication flow. The BFF is the login service, separate from the core API.
| Action | BFF route | Request parameters |
|---|---|---|
| Start sign-in | GET /proxy/v1/login | Fresh login nonce and approved full redirect URI |
| Exchange the callback | POST /proxy/v1/tokens | Original login nonce and returned state |
| Renew the grant | POST /proxy/v1/refresh | authorizationId from the grant's id |
The POST values are request parameters. URL-encode them; do not assume the service accepts a JSON body. Append the routes to the approved BFF origin. If your base already ends in /proxy/v1, include that prefix only once.
| BFF response | Pass to Consumer applySession |
|---|---|
accessToken | accessToken |
id | authorizationId; this is not a DeveloperId or consumer ID |
expiry | expirySeconds, the remaining lifetime in seconds |
If your host stores an expiry deadline, calculate floor((deadlineMillis - nowMillis) / 1000) at the call. Renew or sign in when the result is not positive. Never reuse an already claimed token exchange.
The BFF checks the full redirect against its client's allowlist. Obtain the approved origin, client/scopes and callback from your access pack. Its login nonce/state are separate from the developer proof created for each API attempt.
With SDK-hosted login, the SDK already performs this exchange and owns renewal. It exposes no token getter. With applySession, your authentication service owns renewal. POS session mapping uses the merchant token and two-argument method.
Access and deployment for your environment still require approval.
After sign-in or app restart
The stored session survives an app restart. Re-create the SDK with the same configuration and make the required API call. On UNAUTHORIZED, sign in again or obtain a new host-supplied token.
- Read an existing wallet: call
wollette.retrievewith a session and developer proof. Firebase/device association is not required. - Use push or payment-device features: call
setRegistrationTokenafter sign-in and on token rotation before using those features, including iOS Bluetooth preparation. - Continue activation: check
walletOnboarding.pendingProgressfor an interrupted operation. If none remains, checkwalletOnboarding.progress. Treat activation statusCompleteas ready for activation-dependent features.
A BaaS account can exist before PIS is complete. A successful retrieve is not an activation check. See Resume activation after a restart for both platform examples.
Concurrent login and sign-out
| Platform | Current behaviour |
|---|---|
| Android | On one SDK instance, login, applySession and clear share a lock. A second call waits while login is awaiting the browser or token exchange. clear is not an immediate cancellation of a pending login. |
| iOS | A newer login or session replacement invalidates an unfinished login with VALIDATION. Only the current attempt may save. clear can complete while login is waiting. |
Allow one sign-in flow at a time. Disable repeated sign-in actions while it runs. On Android, finish or cancel the active login flow before expecting clear to finish; test this interaction in your app.
When a session is replaced, protected in-flight API work for the old session is rejected with VALIDATION. Changing consumers also clears wallet-form storage and any saved recovery operation for the previous consumer; both platforms clear previous native consumer payment keys. On iOS, stop the separately retained Bluetooth client before changing account/consumer. On iOS, hosted login installs its session before payment-key cleanup, so a cleanup error can occur after the new session was stored; the replacement is not atomic. Android invalidates previous payment keys before writing a replacement session.
End a session
Call clear and handle storage failures before completing your sign-out UI. It removes local SDK state, not server-side activation or device association. A successful password change also invalidates the session. See Sign out and switch consumers.
Sessions in hosted forms
The SDK injects the current session into the WebView before each hosted form opens. It never puts tokens in form URLs. A refreshed token is supplied at the next opening.
POS sessions are separate
Merchant sessions are host-managed and memory-only. POS has no hosted login or automatic refresh. Use Merchant sessions and terminals; consumer renewal and cleanup rules do not describe POS.
Screen ownership and process restart
Keep the SDK and provider in an application service container. Screens own one coroutine/Task and cancel it when discarded; they do not call clear merely to navigate away. Android hosted login pauses the Activity to show the browser, so pause alone is not a reason to cancel sign-in.
After process restart, recreate the same service configuration. Read explicitly using a stored hosted session and handle a sign-in-required error. Host-managed sessions must be restored or renewed by your authentication service. POS sessions are memory-only and need reattachment before selecting the original terminal and inspecting its retained operation.
During logout, retain the existing partial-cleanup handling. Stop the separately retained iOS Bluetooth client before consumer changes; ordinary session cleanup does not own that client.