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.renewable.Bearer, nebius.aio.token.service_account.ServiceAccountBearer, nebius.aio.token.static.Bearer, nebius.aio.token.token.NamedBearer
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())
| Async Method | close |
Close the bearer and any wrapped resources. |
| Method | receiver |
Return a Receiver to be used for a single request. |
| 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.BearerClose 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.renewable.Bearer, nebius.aio.token.service_account.ServiceAccountBearer, nebius.aio.token.static.Bearer, nebius.aio.token.token.NamedBearernebius.aio.token.federation_bearer.Bearer, nebius.aio.token.file_cache.file_bearer.PureFileCacheBearer, nebius.aio.token.token.NamedBearerOptional 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.renewable.Bearer, nebius.aio.token.service_account.ServiceAccountBearer, nebius.aio.token.token.NamedBearerReturn the wrapped bearer or None if not wrapping.
Subclasses that decorate or compose another bearer should override this property to return the inner bearer.