KSharedPrefsTokenStore

class KSharedPrefsTokenStore(context: Context, prefsName: String = "kindling_tokens", accessTokenKey: String = "access_token", refreshTokenKey: String = "refresh_token") : KTokenStore(source)

KTokenStore backed by plain SharedPreferences.

Tokens are stored in cleartext. Suitable for development or low-sensitivity apps. For production, prefer KEncryptedTokenStore.

Parameters

context

Android Context used to open SharedPreferences.

prefsName

SharedPreferences file name.

accessTokenKey

Key used to store the access token.

refreshTokenKey

Key used to store the refresh token.

Constructors

Link copied to clipboard
constructor(context: Context, prefsName: String = "kindling_tokens", accessTokenKey: String = "access_token", refreshTokenKey: String = "refresh_token")

Functions

Link copied to clipboard
open suspend override fun clear()

Removes all stored tokens.

Link copied to clipboard
open suspend override fun getAccessToken(): String?

Returns the current access token, or null if none is stored.

Link copied to clipboard
open suspend override fun getRefreshToken(): String?

Returns the current refresh token, or null if none is stored.

Link copied to clipboard
open suspend override fun saveTokens(accessToken: String?, refreshToken: String?)

Persists both tokens.