diff --git a/pocketoptionapi_async/client.py b/pocketoptionapi_async/client.py index 6b2f59b..23fc41b 100644 --- a/pocketoptionapi_async/client.py +++ b/pocketoptionapi_async/client.py @@ -660,11 +660,16 @@ def _format_session_message(self) -> str: """Format session authentication message""" # Always create auth message from components using constructor parameters # This ensures is_demo parameter is respected regardless of SSID format + # Include all fields that the browser sends for full compatibility + # CRITICAL: Use 'sessionToken' (not 'session') to match browser format auth_data = { - "session": self.session_id, + "sessionToken": self.session_id, "isDemo": 1 if self.is_demo else 0, - "uid": self.uid, + "uid": str(self.uid), # Browser sends uid as string "platform": self.platform, + "lang": "en", + "currentUrl": "cabinet", + "isChart": 1, } if self.is_fast_history: @@ -682,7 +687,8 @@ def _parse_complete_ssid(self, ssid: str) -> None: json_part = ssid[json_start:json_end] data = json.loads(json_part) - self.session_id = data.get("session", "") + # Accept both 'session' and 'sessionToken' (browser uses sessionToken) + self.session_id = data.get("session", "") or data.get("sessionToken", "") # Store original demo value from SSID, but don't override the constructor parameter self._original_demo = bool(data.get("isDemo", 1)) # Keep the is_demo value from constructor - don't override it diff --git a/tools/get_ssid.py b/tools/get_ssid.py index cf0efb5..78cade2 100644 --- a/tools/get_ssid.py +++ b/tools/get_ssid.py @@ -67,9 +67,8 @@ def get_pocketoption_ssid(): cabinet_base_url = "https://pocketoption.com/en/cabinet" target_cabinet_url = "https://pocketoption.com/en/cabinet/demo-quick-high-low/" # Regex to capture the entire "42[\"auth\",{...}]" string. - # This pattern is designed to be robust and capture the full authentication message, - # regardless of the specific content of the 'session' field (e.g., simple string or serialized PHP array). - ssid_pattern = r'(42\["auth",\{"session":"[^"]+","isDemo":\d+,"uid":\d+,"platform":\d+,"isFastHistory":(?:true|false)\}\])' + # Made more flexible to handle different auth message formats. + ssid_pattern = r'(42\["auth",\{[^\}]+\}\])' logger.info(f"Navigating to login page: {login_url}") driver.get(login_url)