Known subclasses: nebius.aio.token.exchangeable.Receiver, nebius.aio.token.federation_bearer.Receiver, nebius.aio.token.file.Receiver, nebius.aio.token.file_cache.async_renewable_bearer.AsynchronousRenewableFileCacheReceiver, nebius.aio.token.file_cache.file_bearer.PureFileCacheReceiver, nebius.aio.token.file_cache.renewable_bearer.RenewableFileCacheReceiver, nebius.aio.token.renewable.Receiver, nebius.aio.token.static.Receiver
Abstract asynchronous token receiver interface.
Implementations fetch bearer tokens from an external source (for example an OAuth token endpoint or a local cache) and expose a small API that the request layer uses to obtain tokens for per-request authentication.
The receiver is responsible for fetching and refreshing the token for one request
only, reflecting the authentication process, while the Bearer class
supports multiple requests and provides per-request receivers on demand.
| Method | can |
Decide whether a failed authentication attempt should be retried. |
| Async Method | fetch |
Fetch a token and record it as the latest value. |
| Property | latest |
Return the latest fetched token or None. |
| Async Method | _fetch |
Low-level asynchronous fetch implementation. |
| Instance Variable | _latest |
The most recently fetched token, or None if no token has been fetched yet. Implementations may update this to support inspection or caching by callers. |
def can_retry(self, err:
Exception, options: dict[ str, str] | None = None) -> bool:
(source)
¶
nebius.aio.token.exchangeable.Receiver, nebius.aio.token.federation_bearer.Receiver, nebius.aio.token.file.Receiver, nebius.aio.token.file_cache.async_renewable_bearer.AsynchronousRenewableFileCacheReceiver, nebius.aio.token.file_cache.file_bearer.PureFileCacheReceiver, nebius.aio.token.file_cache.renewable_bearer.RenewableFileCacheReceiver, nebius.aio.token.renewable.Receiver, nebius.aio.token.static.ReceiverDecide whether a failed authentication attempt should be retried.
Implementations inspect err (for example gRPC status codes or
specific exception types) and optional options to decide whether a
fresh call to fetch is likely to succeed (for example after
refreshing credentials).
Default implementations should return False.
| Parameters | |
err:Exception | The exception that triggered the retry decision. |
options:dict[str, str] or None | Optional implementation-specific options. |
| Returns | |
bool | True when a retry is advisable, otherwise False. |
float | None = None, options: dict[ str, str] | None = None) -> Token:
(source)
¶
Fetch a token and record it as the latest value.
This method calls the concrete _fetch implementation and stores
the result on _latest before returning it.
| Parameters | |
timeout:optional float | Optional timeout in seconds forwarded to the fetch. |
| options:optional dict[str, str] | Optional implementation-specific options. |
| Returns | |
Token | The fetched Token. |
async def _fetch(self, timeout:
float | None = None, options: dict[ str, str] | None = None) -> Token:
(source)
¶
nebius.aio.token.exchangeable.Receiver, nebius.aio.token.federation_bearer.Receiver, nebius.aio.token.file.Receiver, nebius.aio.token.file_cache.async_renewable_bearer.AsynchronousRenewableFileCacheReceiver, nebius.aio.token.file_cache.file_bearer.PureFileCacheReceiver, nebius.aio.token.file_cache.renewable_bearer.RenewableFileCacheReceiver, nebius.aio.token.renewable.Receiver, nebius.aio.token.static.ReceiverLow-level asynchronous fetch implementation.
Subclasses must implement this method to perform the actual token
retrieval. This method is intentionally prefixed with an underscore to
indicate it is the minimal primitive; callers should use
fetch which records the result in _latest.
| Parameters | |
timeout:optional float | Optional timeout in seconds for the fetch operation. |
| options:optional dict[str, str] | Optional implementation-specific options forwarded by the request layer. |
| Returns | |
Token | A freshly fetched Token. |