getValidAccessToken

suspend fun getValidAccessToken(leewaySeconds: Int = 60, autoRefresh: Boolean = true): String

Returns a valid access token, refreshing it when necessary.

Return

Bearer access token to use in Spotify Web API requests.

Parameters

leewaySeconds

Safety window in seconds before actual expiration when the token is treated as expired.

autoRefresh

Whether to automatically execute Refresh Token flow when the current token is missing or expired.