Skip to content

BearerTokenAuth

Part of Configuration & authentication in the Python API reference.

Related guidance: getting-started/configuration, getting-started/authentication, security/credentials.

Runnable examples: preflight.py.

from picogrid_ecn_client import BearerTokenAuth

Configure MQTT CONNECT authentication with a current bearer token.

BearerTokenAuth(
*,
kind: Literal['bearer'] = 'bearer',
username: str | None = None,
token: SecretStr | None = None,
token_provider: Callable[[], Coroutine[Any, Any, str]] | None = None,
credentials_provider: Callable[[], Coroutine[Any, Any, tuple[str, str]]] | None = None,
)

Source · auth.py

NameTypeRequiredDefaultConstraintsDescription
kindLiteral[‘bearer’]no‘bearer’Authentication discriminator; always ‘bearer’.
usernamestr | NonenoNonemin_length=1, max_length=256Optional MQTT username, from 1 through 256 characters; a credentials provider supplies it instead, and loopback mock use may infer it.
tokenSecretStr | NonenoNoneOptional static MQTT CONNECT token of at most 65,535 UTF-8 bytes; its value is excluded from representations and public error text.
token_providerCallable[[], Coroutine[Any, Any, str]] | NonenoNoneOptional cooperative async provider for the current token; excluded from serialization and representations.
credentials_providerCallable[[], Coroutine[Any, Any, tuple[str, str]]] | NonenoNoneOptional cooperative async provider returning one current username-token pair from the same credential generation; excluded from serialization and representations.

Version 0.2.0 · branch main