class Bearer(ParentBearer): (source)
Constructor: Bearer(requester, channel, max_retries)
Bearer that creates receivers performing token exchange.
The bearer accepts either a concrete gRPC channel or an awaitable
resolving to one. The channel is wrapped in a
TokenExchangeServiceClient and used by receivers to perform
the exchange RPC.
Example
Construct a bearer and use it to initialize the SDK:
from asyncio import Future
from nebius.sdk import SDK
from nebius.aio.token.exchangeable import Bearer
from nebius.base.service_account.pk_file import Reader as PKReader
# Create requester from private key
requester = PKReader(
service_account_private_key_file_name="path/to/private_key.pem",
service_account_id="your-service-account-id",
service_account_public_key_id="your-public-key-id",
)
# Create a future for the channel that will be resolved with the SDK
channel_future = Future()
sdk = SDK(credentials=Bearer(requester=requester, channel=channel_future))
# Resolve the future with the newly created SDK
channel_future.set_result(sdk)
| Parameters | |
| requester | Object that knows how to build an exchange request for the current service account. |
| channel | gRPC channel or awaitable resolving to one. If
omitted, callers must call set_channel before
obtaining a receiver. |
| max | Default retry attempts for receivers created by this bearer. |
| Method | __init__ |
Create an exchangeable bearer. |
| Method | receiver |
Return a Receiver that performs exchanges. |
| Method | set |
Set the gRPC channel or awaitable channel used for exchanges. |
| Instance Variable | _max |
Undocumented |
| Instance Variable | _requester |
Undocumented |
| Instance Variable | _svc |
Undocumented |
Inherited from Bearer:
| Async Method | close |
Close the bearer and any wrapped resources. |
| Property | name |
Optional human-readable name for the bearer. |
| Property | wrapped |
Return the wrapped bearer or None if not wrapping. |
TokenRequester, channel: ClientChannelInterface | DeferredChannel | None = None, max_retries: int = 2):
(source)
¶
Create an exchangeable bearer.
nebius.aio.token.token.Bearer.receiverReturn a Receiver that performs exchanges.
| Returns | |
Receiver | A Receiver instance. |
| Raises | |
ValueError | if no channel has been configured on the bearer. |
Set the gRPC channel or awaitable channel used for exchanges.
The function accepts either a concrete ClientChannelInterface
or an awaitable resolving to one. When an awaitable is supplied,
the bearer lazily constructs a stub coroutine that awaits the
channel and then constructs the TokenExchangeServiceClient.
| Parameters | |
channel:ClientChannelInterface | DeferredChannel | None | The channel or awaitable resolving to a channel. |
TokenExchangeServiceClient | Coroutine[ Any, Any, TokenExchangeServiceClient] | None =
(source)
¶
Undocumented