Known subclasses: nebius.aio.token.exchangeable.Bearer, nebius.aio.token.federated_credentials.FederatedCredentialsBearer, nebius.aio.token.federation_account.FederationBearer, nebius.aio.token.federation_bearer.Bearer, nebius.aio.token.file.Bearer, nebius.aio.token.file_cache.async_renewable_bearer.AsynchronousRenewableFileCacheBearer, nebius.aio.token.file_cache.file_bearer.PureFileCacheBearer, nebius.aio.token.file_cache.renewable_bearer.RenewableFileCacheBearer, nebius.aio.token.impersonated.Bearer, nebius.aio.token.impersonated.CachedBearer, nebius.aio.token.renewable.Bearer, nebius.aio.token.service_account.ServiceAccountBearer, nebius.aio.token.static.Bearer, nebius.aio.token.token.NamedBearer, nebius.aio.metrics._InstrumentedBearer
Abstract provider of Receiver instances.
A Bearer supplies receivers for per-request authenticators. Bearers may be composed (wrapping other Bearers) to add behaviour such as caching, refreshing, or naming.
Treat a stateful bearer as owned by one SDK. The built-in channel calls it on that SDK's internal event loop and closes it with the SDK. Do not attach one bearer instance to SDKs with different loops unless the implementation is thread-safe, loop-neutral, and explicitly supports concurrent use and independent close calls.
Example
Implement a custom bearer:
from nebius.sdk import SDK
from nebius.aio.token.token import Bearer, Receiver, Token
class MyBearer(Bearer):
def receiver(self) -> Receiver:
return MyReceiver()
class MyReceiver(Receiver):
async def _fetch(self, timeout=None, options=None) -> Token:
return Token("my-token")
def can_retry(self, err, options=None) -> bool:
return False
sdk = SDK(
credentials=MyBearer(),
user_agent_prefix="example-application/1.0",
)
| Class Method | default |
Return this bearer's default fully qualified metric provider label. |
| Async Method | close |
Close the bearer and any wrapped resources. |
| Method | receiver |
Return a Receiver to be used for a single request. |
| Property | acquisition |
Return how long one fetch through this bearer can take, or None. |
| Property | metrics |
Provider label used for auth metrics. |
| Property | name |
Optional human-readable name for the bearer. |
| Property | wrapped |
Return the wrapped bearer or None if not wrapping. |
nebius.aio.token.file_cache.async_renewable_bearer.AsynchronousRenewableFileCacheBearer, nebius.aio.token.renewable.Bearer, nebius.aio.metrics._InstrumentedBearerClose the bearer and any wrapped resources.
| Parameters | |
grace:optional float | Optional graceful shutdown timeout in seconds. |
nebius.aio.token.exchangeable.Bearer, nebius.aio.token.federated_credentials.FederatedCredentialsBearer, nebius.aio.token.federation_account.FederationBearer, nebius.aio.token.federation_bearer.Bearer, nebius.aio.token.file.Bearer, nebius.aio.token.file_cache.async_renewable_bearer.AsynchronousRenewableFileCacheBearer, nebius.aio.token.file_cache.file_bearer.PureFileCacheBearer, nebius.aio.token.file_cache.renewable_bearer.RenewableFileCacheBearer, nebius.aio.token.impersonated.Bearer, nebius.aio.token.impersonated.CachedBearer, nebius.aio.token.renewable.Bearer, nebius.aio.token.service_account.ServiceAccountBearer, nebius.aio.token.static.Bearer, nebius.aio.token.token.NamedBearer, nebius.aio.metrics._InstrumentedBearernebius.aio.token.federation_account.FederationBearer, nebius.aio.token.federation_bearer.Bearer, nebius.aio.token.file_cache.async_renewable_bearer.AsynchronousRenewableFileCacheBearer, nebius.aio.token.file_cache.renewable_bearer.RenewableFileCacheBearer, nebius.aio.token.impersonated.Bearer, nebius.aio.token.impersonated.CachedBearer, nebius.aio.token.renewable.Bearer, nebius.aio.token.token.NamedBearer, nebius.aio.metrics._InstrumentedBearerReturn how long one fetch through this bearer can take, or None.
A cache that bounds a shared fetch asks only its immediate bearer for
the budget. A bearer that owns an operation timeout returns it. A bearer
that adds an operation to a wrapped bearer returns the composed budget.
A transparent wrapper returns the budget of the wrapped bearer. The
default is None: the bearer declares no budget, and a cache uses its
own default. A non-positive budget means that the fetch fails at once.
nebius.aio.token.file_cache.async_renewable_bearer.AsynchronousRenewableFileCacheBearer, nebius.aio.token.file_cache.file_bearer.PureFileCacheBearer, nebius.aio.token.file_cache.renewable_bearer.RenewableFileCacheBearer, nebius.aio.token.impersonated.Bearer, nebius.aio.token.renewable.Bearer, nebius.aio.metrics._InstrumentedBearerProvider label used for auth metrics.
Custom bearers may override this property to control their metric provider label. By default the label is the fully qualified class name, or the wrapped bearer's provider label for wrapper bearers.
nebius.aio.token.federation_bearer.Bearer, nebius.aio.token.file_cache.file_bearer.PureFileCacheBearer, nebius.aio.token.impersonated.Bearer, nebius.aio.token.token.NamedBearer, nebius.aio.metrics._InstrumentedBearerOptional human-readable name for the bearer.
This may be used in some wrapper providers to cache the results of the shared receiver, or to report diagnostics.
This name should reflect the unique configuration of the bearer.
If the bearer wraps another bearer, the default behaviour is to forward the name lookup to the wrapped instance.
nebius.aio.token.federated_credentials.FederatedCredentialsBearer, nebius.aio.token.federation_account.FederationBearer, nebius.aio.token.file_cache.async_renewable_bearer.AsynchronousRenewableFileCacheBearer, nebius.aio.token.file_cache.renewable_bearer.RenewableFileCacheBearer, nebius.aio.token.impersonated.Bearer, nebius.aio.token.impersonated.CachedBearer, nebius.aio.token.renewable.Bearer, nebius.aio.token.service_account.ServiceAccountBearer, nebius.aio.token.token.NamedBearer, nebius.aio.metrics._InstrumentedBearerReturn the wrapped bearer or None if not wrapping.
Subclasses that decorate or compose another bearer should override this property to return the inner bearer.