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 |
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
33 34 35 36 37 38 39 40 41 42 43 | |
call_with_auth_refresh
call_with_auth_refresh(fn: Callable[[], T]) -> T
Run a qlam API call, refreshing credentials once on a 403.
If fn raises an APIError with status 403, 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 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
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |