Mixins
AuthMixin dataclass
AuthMixin(
*, context_name: str, qpu_mode: str | None = None
)
Bases: ConfigMixin
flowchart TD
bloqade.core.device.mixins.AuthMixin[AuthMixin]
bloqade.core.device.mixins.ConfigMixin[ConfigMixin]
bloqade.core.device.mixins.ConfigMixin --> bloqade.core.device.mixins.AuthMixin
click bloqade.core.device.mixins.AuthMixin href "" "bloqade.core.device.mixins.AuthMixin"
click bloqade.core.device.mixins.ConfigMixin href "" "bloqade.core.device.mixins.ConfigMixin"
Mixin that provides authentication helpers for qlam API clients.
Inherits qlam configuration from ConfigMixin and manages an AppContext scoped to context_name. Ensures the client is authenticated before making API calls.
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 |
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
43 44 45 46 47 48 49 50 51 52 53 | |
call_with_auth_refresh
call_with_auth_refresh(fn: Callable[[], T]) -> T
Run a qlam API call, refreshing credentials once on a 401 or 403.
If fn raises an APIError with status 401 (token expired) or 403 (access denied), a best-effort non-interactive credential refresh is attempted via AuthClient. When the refresh updates at least one provider's credentials, fn is invoked again. Any other error, or a refresh that produces no fresh credentials, propagates the original exception.
Only one retry is attempted; a second 401/403 is re-raised.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fn | Callable[[], T] | Zero-argument callable that performs the qlam API call. | required |
Returns:
| Name | Type | Description |
|---|---|---|
T | T | The value returned by |
Raises:
| Type | Description |
|---|---|
APIError | When |
Source code in src/bloqade/core/device/mixins.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
ConfigMixin dataclass
ConfigMixin(
*, context_name: str, qpu_mode: str | None = None
)
Mixin that provides qlam connection and API configuration.
Attributes:
| Name | Type | Description |
|---|---|---|
context_name | str | Name of the qlam context to use. |
qpu_mode | str | None | Explicit qlam QPU mode to use for API calls. When None, qlam-core resolves it from configuration. |