OAuthAuthorizationProvider
An AuthorizationProvider that holds an OAuth bearer access token and refreshes it via refreshTokenHandler. Mirrors SwiftyNetwork's OAuthAuthorizationProvider.
Concurrent refreshes are coalesced: if several requests 401 at once, refreshTokenHandler runs exactly once and all callers await the same result — the Kotlin analog of SwiftyNetwork's in-flight refresh Task, and of Novalingo's sign-in mutex choke point. When a late 401 rejects a token another request has already replaced, NetworkClient reuses the current token without refreshing it again. This check and refresh admission share the mutex.
Parameters
the token to start with.
mints a fresh access token, or returns null if refresh failed.
Functions
Cancels the internal coroutine scope used to coalesce refreshes. Call when the provider is discarded (e.g. on sign-out): any in-flight refresh is cancelled, and it and every subsequent refreshAuthorizationIfNeeded report false, so requests fail with NetworkError.AuthorizationRefreshFailed instead of refreshing.
The current access token.
The authorization to attach to the next request.
Attempts to refresh the credential after a 401. Returns true if a fresh credential is now available (and the request should be retried), false otherwise.