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.impersonated.Receiver, nebius.aio.token.renewable.Receiver, nebius.aio.token.static.Receiver, nebius.aio.metrics._InstrumentedReceiver
Abstract asynchronous token receiver interface.
Implementations get bearer tokens from an external source, such as an OAuth endpoint or local cache. The request layer uses this interface for per-request authentication.
A receiver gets and refreshes a token for one request. A Bearer
supports multiple requests and supplies a receiver for each request.
The built-in channel calls receivers on its internal SDK event loop. A custom receiver must be thread-safe and loop-neutral. It must not retain asyncio state that belongs to an application loop.
| 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.impersonated.Receiver, nebius.aio.token.renewable.Receiver, nebius.aio.token.static.Receiver, nebius.aio.metrics._InstrumentedReceiverDecide whether a failed authentication attempt should be retried.
Inspect err and optional options. Return whether a new
fetch call is likely to succeed, for example after credential
refresh.
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)
¶
nebius.aio.metrics._InstrumentedReceiverFetch 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.impersonated.Receiver, nebius.aio.token.renewable.Receiver, nebius.aio.token.static.Receiver, nebius.aio.metrics._InstrumentedReceiverLow-level asynchronous fetch implementation.
Subclasses must implement this token-retrieval method. Call
fetch instead of this internal method. fetch 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. |