SpotifyClient

class SpotifyClient(tokenProvider: TokenProvider, config: SpotifyConfig = SpotifyConfig(), httpClient: HttpClient? = null)

Single entry point wiring one shared HttpClient and TokenProvider into every Spotify domain API.

Each domain is exposed lazily so only the ones actually used get constructed. When no httpClient is injected, SpotifyClient builds its own client via SpotifyHttpClientFactory (configured with config) and owns it; close then releases it. An injected httpClient is assumed to be managed by the caller and is left open by close.

Use the primary constructor with a TokenProvider for custom or refreshing token sources, or the secondary constructor with a static String access token for the common case.

Constructors

Link copied to clipboard
constructor(accessToken: String, config: SpotifyConfig = SpotifyConfig(), httpClient: HttpClient? = null)

Convenience constructor for a static access token. Wraps accessToken in a per-instance TokenProvider; no global state is used. For refreshing tokens, use the primary constructor with a custom TokenProvider.

constructor(tokenProvider: TokenProvider, config: SpotifyConfig = SpotifyConfig(), httpClient: HttpClient? = null)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
open fun close()

Closes the underlying HttpClient, but only when SpotifyClient created and owns it.