AccessTokenProvider

org.llm4s.llmconnect.auth.AccessTokenProvider
@Stable

Supplies the bearer token for each request, refreshing it as needed.

Stable since #1818: OpenAICompatibleClient.Credential.Dynamic takes one. An implementation should return a failure as a Left rather than throw; a client that calls it turns a thrown exception into an AuthenticationError all the same.

One of three sibling suppliers of a credential, each with the one method current(): ApiKeyProvider (an API key), this (a bearer token) and IdentityTokenProvider (the identity token a token exchange presents).

Attributes

Source
AccessTokenProvider.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Abstract methods

A token believed valid now. Build it with Secret.token(value), which keeps it out of logs and errors.

A token believed valid now. Build it with Secret.token(value), which keeps it out of logs and errors.

Attributes

Source
AccessTokenProvider.scala

Concrete methods

def invalidate(rejected: Secret): Unit

Reports that the server rejected rejected. A provider that caches drops the cached token only if it is that token, so concurrent calls that all saw a 401 for the same token cause one refresh, and a late report about an older token does not discard a newer one.

Reports that the server rejected rejected. A provider that caches drops the cached token only if it is that token, so concurrent calls that all saw a 401 for the same token cause one refresh, and a late report about an older token does not discard a newer one.

Does nothing by default, which suits a provider that caches nothing: every current call then asks afresh. With it defaulted the trait has one abstract method, so a lambda is a provider: () => readToken().map(Secret.token).

Attributes

Source
AccessTokenProvider.scala