DpopMigrationManager

Headless helper that upgrades a user's Bearer refresh token to a DPoP-bound one when needed.

This class has no UI. It decides whether a migration is needed, runs upgradeToDPoP and reports an Outcome. Note that the SDK itself presents TokenMigrationActivity while the upgrade runs. Apps that want their own "securing your session" screen can use isMigrationNeeded to decide whether to show it.

The account's token type (DPoPKeyManager.isDPoPTokenType) is the single source of truth: nothing is persisted by this class. On failure the user is left on their existing session and the next call retries.

Contract:

  • Every call completes exactly once, on the main thread (the SDK's own callbacks may arrive on a background thread).

  • Concurrent calls for the same user share a single upgrade. This matters because an activity's onResume fires again when TokenMigrationActivity finishes.

  • Outcome.Migrated is reported only if the upgraded account's token type is DPoP; otherwise Outcome.Failed with REASON_NOT_DPOP_BOUND.

  • If the SDK never reports back (for example the user backs out of TokenMigrationActivity), all waiting callers get Outcome.Failed once the timeout elapses and the next call may start a new upgrade. A late success from the timed-out upgrade is still honored: it completes any upgrade that was started since for the same user.

Logcat: adb logcat -s DPoPMigration

Types

Link copied to clipboard
fun interface Callback

Java-friendly completion callback, invoked once on the main thread.

Link copied to clipboard
sealed class Outcome

The result of a migration request.

Properties

Link copied to clipboard

Default time to wait for the SDK to report a result, in milliseconds.

Link copied to clipboard

Reason carried by Outcome.Failed when the upgrade completed without a DPoP-bound token.

Link copied to clipboard

Reason carried by Outcome.Failed when the timeout elapses.

Functions

Link copied to clipboard
fun isMigrationNeeded(user: UserAccount? = UserAccountManager.getInstance().currentUser): Boolean

Cheap, side-effect free check: would migrateIfNeeded start (or join) an upgrade now? Returns true while an upgrade is already in flight for user, so UI shown for it stays up. Safe to call from any thread; the result is only a snapshot.

Link copied to clipboard
suspend fun migrateIfNeeded(user: UserAccount? = UserAccountManager.getInstance().currentUser, timeoutMs: Long = DEFAULT_TIMEOUT_MS): DpopMigrationManager.Outcome

Upgrades user (default: the current user) to a DPoP-bound refresh token if needed.

fun migrateIfNeeded(user: UserAccount? = UserAccountManager.getInstance().currentUser, timeoutMs: Long = DEFAULT_TIMEOUT_MS, callback: DpopMigrationManager.Callback)

Callback flavor of migrateIfNeeded for Java callers. callback is invoked once on the main thread.