mirror of
https://github.com/usestrix/strix.git
synced 2026-10-10 03:28:11 +00:00
fix(cli): reject sign-in responses without an API token
This commit is contained in:
parent
8dd26f016f
commit
67082e21d9
1 changed files with 8 additions and 1 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue