fix(cli): reject sign-in responses without an API token

This commit is contained in:
Alex Schapiro 2026-08-26 21:02:57 +00:00
parent 8dd26f016f
commit 67082e21d9

View file

@ -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()