OAuthConfig
OAuth2 authentication configuration for the Volvo ID identity system.
Handles the complete OAuth2 Bearer token lifecycle including automatic refresh. When the access token expires (401 response), the client automatically requests a new one from the Volvo ID token endpoint using the refresh token.
Refresh token rotation: Volvo ID returns a new refresh token with each refresh. The old refresh token is immediately invalidated. Use onTokensRefreshed to persist the new tokens so they survive app restarts.
Token lifecycle:
Access tokens are short-lived (typically minutes)
Refresh tokens expire after 7 days of inactivity
Maximum grant lifetime is 6 months with continuous refreshing
After 6 months the user must re-authenticate
val auth = OAuthConfig(
accessToken = storedAccessToken,
refreshToken = storedRefreshToken,
clientId = "your-client-id",
clientSecret = "your-client-secret",
onTokensRefreshed = { newAccess, newRefresh ->
storage.save(newAccess, newRefresh)
}
)Constructors
Properties
The current OAuth2 access token (Bearer token for API calls)
OAuth2 client ID from the Volvo Developer Portal
OAuth2 client secret from the Volvo Developer Portal
Callback invoked after a successful token refresh with the new access token and new refresh token. Must persist both tokens — the old refresh token is invalidated immediately.
The current refresh token for obtaining new access tokens