TokenProvider

interface TokenProvider

The TokenProvider interface provides the functionality to get the tokens, validate the tokens, refresh the tokens, and clear the tokens. This interface is used in TokenProviderImpl

Functions

Link copied to clipboard
abstract suspend fun clearTokens(context: Context): Unit?

Clear the tokens from the token data store. This method will clear the tokens from the data store. After calling this method, developer needs to perform the authorization flow again to get the tokens.

Link copied to clipboard
abstract suspend fun getAccessToken(context: Context): String?

Get the access token from the token.

Link copied to clipboard
abstract suspend fun getAccessTokenExpirationTime(context: Context): Long?

Get the access token expiration time from the token.

Link copied to clipboard
abstract suspend fun getDecodedIDToken(context: Context): LinkedHashMap<String, Any>

Get the decoded ID token

Link copied to clipboard
abstract suspend fun getIDToken(context: Context): String?

Get the ID token from the token.

Link copied to clipboard
abstract suspend fun getRefreshToken(context: Context): String?

Get the refresh token from the token.

Link copied to clipboard
abstract suspend fun getScope(context: Context): String?

Get the scope from the token.

Link copied to clipboard
abstract suspend fun performAction(context: Context, action: suspend (String?, String?) -> Unit)

Perform an action with fresh tokens. This method will perform the action with fresh tokens and save the updated token state in the data store. Developer can directly use this method perform an action with fresh tokens, without worrying about refreshing the tokens. If this action fails, it will throw an Exception.

Link copied to clipboard
abstract suspend fun performRefreshTokenGrant(context: Context)

Perform refresh token grant. This method will perform the refresh token grant and save the updated token state in the data store. If refresh token grant fails, it will throw an Exception.

Link copied to clipboard
abstract suspend fun validateAccessToken(context: Context): Boolean?

Validate the access token, by checking the expiration time of the access token, and by checking if the access token is null or empty.