fix: login response parsing a00.r.r (v0.1.5)

This commit is contained in:
2026-04-15 13:15:08 +02:00
parent a680fb2e51
commit 7372648894
4 changed files with 17 additions and 17 deletions
+10 -13
View File
@@ -100,24 +100,21 @@ class FamilyWallClient:
if "ex" in body or "un" in body:
error_data = body.get("ex", body.get("un"))
print(
f"[LOGIN ERROR] status={response.status_code} body={body}",
file=sys.stderr,
)
_debug_log("LOGIN ERROR", f"status={response.status_code} body={body}")
msg = f"Login failed: {error_data}"
raise FamilyWallError(msg, response_data=body)
if "r" not in body:
print(
f"[LOGIN ERROR] status={response.status_code} body={body}",
file=sys.stderr,
)
raise FamilyWallError("Login failed: unexpected response format", response_data=body)
# Response structure: {"a00": {"r": {"r": {"tokenCsrf": "...", ...}}}}
try:
session_id: str = body["a00"]["r"]["r"]["tokenCsrf"]
except (KeyError, TypeError) as exc:
_debug_log("LOGIN ERROR", f"status={response.status_code} body={body}")
raise FamilyWallError(
"Login failed: unexpected response format", response_data=body
) from exc
# Extract JSESSIONID from the Set-Cookie header
session_id = response.cookies.get("JSESSIONID")
if not session_id:
raise FamilyWallError("Login succeeded but no JSESSIONID cookie returned.")
raise FamilyWallError("Login succeeded but tokenCsrf is empty.")
self._session_id = session_id
logger.debug("Logged in; session acquired")