class documentation
class Authenticator(ABC): (source)
Known subclasses: nebius.aio.authorization.token.TokenAuthenticator
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 |
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:
async def authenticate(self, metadata:
Metadata, timeout: float | None = None, options: dict[ str, str] | None = None):
(source)
¶
overridden in
nebius.aio.authorization.token.TokenAuthenticatorAuthenticate by modifying the metadata before sending an RPC.
| Parameters | |
metadata:nebius.base.metadata.Metadata | The 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 float | Optional 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:
def can_retry(self, err:
Exception, options: dict[ str, str] | None = None) -> bool:
(source)
¶
overridden in
nebius.aio.authorization.token.TokenAuthenticatorIndicate whether a failed authentication attempt or failed request may be
retried with a fresh authentication, calling to authenticate.
| Parameters | |
err:Exception | The 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 | |
| bool | True when the authentication should be retried, otherwise False. |