AuthManager

Manages the full VW identity OAuth 2.0 flow: login, token persistence, transparent refresh, and silent re-login when refresh tokens expire.

Most consumers should use the rsdev.ovh.weconnect.WeConnect facade instead of interacting with this class directly.

Parameters

tokenStore

encrypted storage for OAuth tokens

Constructors

Link copied to clipboard
constructor(tokenStore: TokenStore)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val authState: StateFlow<AuthState>

Reactive stream of authentication state changes.

Functions

Link copied to clipboard
open override fun close()
Link copied to clipboard
open suspend override fun ensureValidToken(): String

Returns a valid access token, refreshing or re-authenticating if necessary.

Link copied to clipboard
fun getSpin(vin: String): String?

Returns the stored security PIN (SPIN) for vin, or null if not set.

Link copied to clipboard

Returns true if there is an active session with stored tokens.

Link copied to clipboard
suspend fun login(username: String, password: String, redirectUri: String = "weconnect://authenticated")

Performs the headless OAuth authorization code flow against the VW identity service.

Link copied to clipboard
suspend fun logout()

Clears all stored tokens, SPINs, and transitions authState to AuthState.LoggedOut.

Link copied to clipboard
fun setSpin(vin: String, spin: String)

Stores a vehicle-specific spin for commands that require it (lock/unlock, auxiliary heating).