class documentation

Factory abstraction that supplies an Authenticator.

Typical usage within the request lifecycle

The Provider is the object passed to request constructors and prior to sending an RPC the request layer calls Provider.authenticator() to obtain an Authenticator.

The Authenticator instance returned by the provider is treated as a per-request authorizer: it is responsible for ensuring the provided nebius.base.metadata.Metadata contains the headers needed for that request only (for example an Authorization bearer token). If an authentication-related failure occurs, the request layer will consult Authenticator.can_retry and will retry with the same authenticator.

Example

A minimal example showing how a provider might be passed into an SDK or request layer. The actual SDK in this repo accepts a provider via the credentials parameter; the example below demonstrates the intent and typical usage:

from nebius.sdk import SDK
from nebius.aio.authorization import Authenticator, Provider

class MyAuthenticator(Authenticator):
    async def authenticate(self, metadata, timeout=None, options=None):
        metadata.add("Authorization", "Bearer my-static-token")

class MyProvider(Provider):
    def authenticator(self):
        return MyAuthenticator()

provider = MyProvider()
sdk = SDK(credentials=provider)  # SDK initialisation (illustrative)
Method authenticator Return a fresh per-request Authenticator instance.
@abstractmethod
def authenticator(self) -> Authenticator: (source) ΒΆ

Return a fresh per-request Authenticator instance.

Returns
AuthenticatorAn authenticator instance.