class documentation

Receiver that performs a token exchange over gRPC.

The receiver constructs an exchange request using the provided nebius.base.service_account.service_account.TokenRequester and calls the TokenExchangeServiceClient.exchange RPC.

Parameters
requesterObject that can construct the exchange request.
serviceEither a ready-made TokenExchangeServiceClient or an awaitable resolving to one (useful when the channel is created asynchronously).
max_retriesMaximum retry attempts for this receiver.
Method __init__ Initialize the receiver.
Method can_retry Decide whether the receiver should attempt another retry.
Async Method _fetch Perform the exchange RPC and return a Token.
Method _raise_request_error Convert a gRPC AioRpcError into a RequestError with diagnostics.
Instance Variable _max_retries Undocumented
Instance Variable _requester Undocumented
Instance Variable _status Undocumented
Instance Variable _svc Undocumented
Instance Variable _trial Undocumented

Inherited from Receiver:

Async Method fetch Fetch a token and record it as the latest value.
Property latest Return the latest fetched token or None.
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 __init__(self, requester: TokenRequester, service: TokenExchangeServiceClient | Awaitable[TokenExchangeServiceClient], max_retries: int = 2): (source)

Initialize the receiver.

def can_retry(self, err: Exception, options: dict[str, str] | None = None) -> bool: (source)

Decide whether the receiver should attempt another retry.

The method honours the per-request OPTION_MAX_RETRIES override if present and parses it as an integer. Invalid values are logged and ignored.

async def _fetch(self, timeout: float | None = None, options: dict[str, str] | None = None) -> Token: (source)

Perform the exchange RPC and return a Token.

Parameters
timeout:float | NoneOptional RPC timeout in seconds forwarded to the underlying gRPC stub.
options:dict[str, str] | NoneOptional map of request-specific options (currently unused).
Returns
TokenA Token representing the exchanged access token.
Raises
nebius.aio.service_error.RequestErrorwhen the RPC returns a service error.
UnsupportedResponseErrorwhen the RPC returns an unexpected payload type.
UnsupportedTokenTypeErrorwhen the received token type is not "Bearer".
def _raise_request_error(self, err: AioRpcError): (source)

Convert a gRPC AioRpcError into a RequestError with diagnostics.

The function extracts request and trace ids from the initial metadata and converts the gRPC status into the SDK's nebius.aio.service_error.RequestError type.

Parameters
err:AioRpcErrorThe original gRPC AioRpcError.
Raises
RequestErroralways raised with enriched diagnostics.
_max_retries = (source)

Undocumented

_requester = (source)

Undocumented

Undocumented

Undocumented

Undocumented