module documentation

Asynchronous bearer token abstractions and the token representation.

This module provides the core abstractions used by the SDK for representing bearer tokens and for supplying per-request token receivers.

Key classes

  • Token -- simple immutable representation of an access token and an
    optional expiration time.
  • Receiver -- asynchronous primitive that can fetch a single
    Token (used per-request by the authentication layer).
  • Bearer -- provider of Receiver instances. Bearers are
    composed to add features like naming, renewal and caching.

Examples

Create a simple token and serialize it:

from nebius.aio.token.token import Token
from datetime import datetime, timezone, timedelta

tok = Token(
        "s3cr3t",
        expiration=datetime.now(timezone.utc) + timedelta(hours=1),
)
print(str(tok))
data = tok.to_dict()

Restore the token from the serialized form:

tok2 = Token.from_dict(data)
assert tok == tok2

Using a static bearer/receiver (see nebius.aio.token.static for concrete implementations) the SDK creates per-request receivers with bearer.receiver() and uses Receiver.fetch to obtain tokens.

Class Bearer Abstract provider of Receiver instances.
Class NamedBearer Simple bearer wrapper that attaches a static name to another bearer.
Class Receiver Abstract asynchronous token receiver interface.
Class Token Representation of a bearer token with optional expiration.
Variable sanitizer Undocumented
sanitizer = (source) ΒΆ

Undocumented