Authentication model
All auth providers implement the same token-provider shape: synchronous and asynchronous token
access for the HTTP clients that SVIClient creates.
Provider flows
The SDK retries a 401 once, but only when the auth provider exposes invalidate().
It calls invalidate(), re-fetches the token, and replays the request. You don't
manage token freshness in application code. StaticTokenProvider has no
invalidate(), so the SDK does not retry a 401 against a static token.
Resolution strategy
When you pass auth= explicitly, SVIClient uses that provider.
When you call SVIClient.from_env(), the SDK resolves auth in this order:
- static access token
- client credentials
- username and password
Why the order matters:
- the most explicit credential wins
- automation-friendly flows are preferred over interactive ones
- the same environment block can support scripts, notebooks, and smoke tests
Provider lifecycles
StaticTokenProviderreturns the same token every timeClientCredentialsTokenProviderexchanges client credentials for a token and refreshes in memoryUsernamePasswordTokenProvideruses the password grant and refresh token when availableAuthorizationCodeTokenProviderruns the PKCE browser flow and then refreshes in memory
Base URL binding
OAuth-capable providers can inherit base_url, TLS verification, and HTTPX options from the
client configuration. That keeps the SAS Logon calls aligned with the service clients.
Practical guidance
- use static tokens when another system owns authentication
- use client credentials for service-to-service workloads
- use username/password only in controlled development environments
- use authorization code with PKCE for interactive user sessions