Skip to content

Mixins

AuthMixin dataclass

AuthMixin(*, context_name: str)

Mixin that provides authentication helpers for qlam API clients.

Manages an AppContext scoped to a qlam context name and ensures the client is authenticated before making API calls.

Attributes:

Name Type Description
context_name str

Name of the qlam context to use.

app_context property

app_context: AppContext

The AppContext used to authenticate and connect to the backend.

Returns:

Name Type Description
AppContext AppContext

An app context scoped to context_name.

authenticate

authenticate()

Ensure the client is authenticated, triggering a login if needed.

Returns:

Type Description

The login result when a login is performed; otherwise None.

Source code in src/bloqade/core/device/mixins.py
29
30
31
32
33
34
35
36
37
38
39
def authenticate(self):
    """Ensure the client is authenticated, triggering a login if needed.

    Returns:
        The login result when a login is performed; otherwise None.
    """
    with AuthClient(self.app_context) as client:
        if client.is_authenticated():
            return

        return client.login()