diff --git a/strix/interface/platform_cli.py b/strix/interface/platform_cli.py index f50e3a8a..90ff82e5 100644 --- a/strix/interface/platform_cli.py +++ b/strix/interface/platform_cli.py @@ -195,7 +195,7 @@ def _run_device_flow( except requests.RequestException: continue if poll.ok: - return _json_object(poll) + return _signed_in_record(poll) error = "" with contextlib.suppress(ValueError, AttributeError): error = str(poll.json().get("error", "")) @@ -213,6 +213,13 @@ def _run_device_flow( raise PlatformAuthError("the sign-in request expired. Run `strix login` again.") +def _signed_in_record(response: requests.Response) -> dict[str, Any]: + record = _json_object(response) + if not str(record.get("api_token") or ""): + raise PlatformAuthError("the server returned a sign-in response without an API token") + return record + + def _json_object(response: requests.Response) -> dict[str, Any]: try: data = response.json()