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.
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())
| 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 | 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.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.