VolvoCars
Main entry point for Volvo Vehicle API operations.
Combines ConnectedVehicle, Energy, and Location APIs into a single client.
Thread Safety: This client is safe for concurrent coroutine execution. A single instance can handle multiple simultaneous requests.
Resource Management: Create one client and reuse it across your application. Call close when done to release underlying HTTP resources. Calling close multiple times is safe.
Authentication: Supports two modes:
OAuth2 with automatic refresh (recommended): Provide OAuthConfig with client credentials. The client automatically refreshes expired tokens via the Volvo ID token endpoint. Use OAuthConfig.onTokensRefreshed to persist rotated tokens.
Static token: Provide a Bearer token directly. When it expires, create a new client with a fresh token.
// OAuth2 with automatic refresh (recommended)
val client = VolvoCars(
VolvoCarsConfig(
apiKey = "your-vcc-api-key",
oauth = OAuthConfig(
accessToken = storedAccessToken,
refreshToken = storedRefreshToken,
clientId = "your-client-id",
clientSecret = "your-client-secret",
onTokensRefreshed = { access, refresh -> save(access, refresh) }
)
)
)
// Static token (testing / short-lived scripts)
val client = VolvoCars(apiKey = "your-key", token = "your-token")See also
for detailed configuration options
for OAuth2 token refresh configuration