class documentation

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.
async def close(self, grace: float | None = None): (source)

Close the bearer and any wrapped resources.

Parameters
grace:optional floatOptional graceful shutdown timeout in seconds.

Optional 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.