From 9a35a57c7f3d67bcddd313e5c0eabab12252f0f8 Mon Sep 17 00:00:00 2001 From: Kevin Bataille Date: Mon, 6 Oct 2025 15:21:21 +0200 Subject: [PATCH] fix(auth): Update API response parsing to handle nested structure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix 'id_user' key not found error by navigating the correct nested path - Extract id_user from data.user.applications[0].users[0].id_user - Add fallback to old structure for backward compatibility - Prevents authentication failures due to API response format changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/auth.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/auth.py b/src/auth.py index c48fcdf..7875402 100644 --- a/src/auth.py +++ b/src/auth.py @@ -77,7 +77,13 @@ class AuthHandler: try: login_data: Dict[str, Any] = response.json() - self.user_id = str(login_data["data"]["user"]["id_user"]) + # Try to find id_user in the nested structure + try: + # First try the new structure: data.user.applications[0].users[0].id_user + self.user_id = str(login_data["data"]["user"]["applications"][0]["users"][0]["id_user"]) + except (KeyError, IndexError, TypeError): + # Fallback to old structure if it exists + self.user_id = str(login_data["data"]["user"]["id_user"]) except (KeyError, ValueError) as e: logging.error(f"Error during login: {str(e)} - Response: {response.text}") return False