OAuthSessionStore

Platform-agnostic session persistence interface. Consumers provide the storage backend — the module handles serialization.

On Android, use EncryptedSharedPreferences (the sample shows how). On JVM desktop, use a file-backed store with appropriate permissions.

Functions

Link copied to clipboard
abstract suspend fun clear()
Link copied to clipboard
abstract suspend fun load(): OAuthSession?
Link copied to clipboard
abstract suspend fun save(session: OAuthSession)

Persists the session. MUST be durable before returning: save is called AFTER the authorization server has already rotated the single-use refresh token, so a write that is deferred (e.g. Android SharedPreferences.apply()) or lost to process death leaves a consumed refresh token on disk — the next cold-start refresh is then rejected as token reuse (invalid_grant) and the whole session is revoked. Prefer synchronous commits (commit(), DataStore updateData) over fire-and-forget writes.