class Receiver(ParentReceiver): (source)
Constructor: Receiver(requester, service, max_retries)
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 | |
| requester | Object that can construct the exchange request. |
| service | Either a ready-made
TokenExchangeServiceClient or an awaitable resolving to
one (useful when the channel is created asynchronously). |
| max | Maximum retry attempts for this receiver. |
| Method | __init__ |
Initialize the receiver. |
| Method | can |
Decide whether the receiver should attempt another retry. |
| Async Method | _fetch |
Perform the exchange RPC and return a Token. |
| Method | _raise |
Convert a gRPC AioRpcError into a RequestError with diagnostics. |
| Instance Variable | _max |
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. |
TokenRequester, service: TokenExchangeServiceClient | Awaitable[ TokenExchangeServiceClient], max_retries: int = 2):
(source)
¶
Initialize the receiver.
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.
float | None = None, options: dict[ str, str] | None = None) -> Token:
(source)
¶
nebius.aio.token.token.Receiver._fetchPerform the exchange RPC and return a Token.
| Parameters | |
timeout:float | None | Optional RPC timeout in seconds forwarded to the underlying gRPC stub. |
options:dict[ | Optional map of request-specific options (currently unused). |
| Returns | |
Token | A Token representing the exchanged access token. |
| Raises | |
nebius.aio.service_error.RequestError | when the RPC returns a service error. |
UnsupportedResponseError | when the RPC returns an unexpected payload type. |
UnsupportedTokenTypeError | when the received token type is not "Bearer". |
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:AioRpcError | The original gRPC AioRpcError. |
| Raises | |
RequestError | always raised with enriched diagnostics. |