class documentation

Abstract interface for performing per-request authentication.

Subclasses must implement authenticate and may implement can_retry to indicate whether authentication failures should be retried, eg code UNAUTHENTICATED and number of calls to authenticate < 3.

Async Method authenticate Authenticate by modifying the metadata before sending an RPC.
Method can_retry Indicate whether a failed authentication attempt or failed request may be retried with a fresh authentication, calling to authenticate.
@abstractmethod
async def authenticate(self, metadata: Metadata, timeout: float | None = None, options: dict[str, str] | None = None): (source)

Authenticate by modifying the metadata before sending an RPC.

Parameters
metadata:nebius.base.metadata.MetadataThe metadata mapping that will be sent with the RPC. Implementations may mutate this mapping in-place to add or update authentication headers (for example the Authorization header).
timeout:optional floatOptional authentication timeout in seconds. Implementations must not exceed this timeout during the whole authentication process.
options:optional dict[str, str]Optional, implementation-specific options passed from the request layer.
@abstractmethod
def can_retry(self, err: Exception, options: dict[str, str] | None = None) -> bool: (source)

Indicate whether a failed authentication attempt or failed request may be retried with a fresh authentication, calling to authenticate.

Parameters
err:ExceptionThe exception raised during authentication or while the RPC was in-flight. Implementations inspect the exception to determine if a retry (for example after refreshing a token) is likely to succeed.
options:optional dict[str, str]Optional implementation-specific options.
Returns
boolTrue when the authentication should be retried, otherwise False.