class documentation

Bearer that exposes a PureFileCacheReceiver for a named token.

Notes

Construction is inexpensive; the cache performs I/O lazily when tokens are accessed via the receiver.

Example

Create a bearer that reads credentials from the default credentials file and caches them for five minutes:

from nebius.aio.token.file_cache.file_bearer import PureFileCacheBearer
from nebius.sdk import SDK

bearer = PureFileCacheBearer('my-service')
sdk = SDK(
    credentials=bearer,
    user_agent_prefix="example-application/1.0",
)
Parameters
nameLogical name for the credential.
cache_fileDestination YAML file used to persist tokens.
throttleThrottle interval for in-memory caching.
metricsOptional auth metrics callbacks used to record cache hits and misses.
providerOptional provider label for emitted auth metrics. Defaults to the fully qualified bearer class name.
Method __init__ Create a bearer backed by a throttled file cache.
Method receiver Return a PureFileCacheReceiver bound to the cache.
Method set_metrics Attach auth metrics callbacks used by subsequently created receivers.
Property metrics_provider Return the metric provider label.
Property name Return the logical name for this bearer.
Instance Variable _cache Undocumented
Instance Variable _metrics Undocumented
Instance Variable _name Undocumented

Inherited from Bearer:

Class Method default_metrics_provider Return this bearer's default fully qualified metric provider label.
Async Method close Close the bearer and any wrapped resources.
Property acquisition_budget Return how long one fetch through this bearer can take, or None.
Property wrapped Return the wrapped bearer or None if not wrapping.
def __init__(self, name: str, cache_file: str | Path = Path(DEFAULT_CONFIG_DIR) / DEFAULT_CREDENTIALS_FILE, throttle: timedelta | float = timedelta(minutes=5), metrics: AuthMetricsLike = None, provider: str | None = None): (source)

Create a bearer backed by a throttled file cache.

def receiver(self) -> ParentReceiver: (source)

Return a PureFileCacheReceiver bound to the cache.

Each call returns a fresh receiver that references the same ThrottledTokenCache instance.

Returns
ParentReceiverA receiver that reads from the shared cache.
def set_metrics(self, metrics: AuthMetricsLike): (source)

Attach auth metrics callbacks used by subsequently created receivers.

@property
metrics_provider: str = (source)

Return the metric provider label.

Return the logical name for this bearer.

Returns
The name provided at construction.

Undocumented

_metrics = (source)

Undocumented

Undocumented