From 9d4ca9ffe977a283eb67680cd8a1ced58efe6f72 Mon Sep 17 00:00:00 2001 From: Jiri Jerabek Date: Tue, 7 Apr 2026 12:43:49 +0200 Subject: [PATCH 1/2] support custom gateway_sessionid --- galaxykit/gw_auth_client.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/galaxykit/gw_auth_client.py b/galaxykit/gw_auth_client.py index c7bbcfc..b5e6908 100644 --- a/galaxykit/gw_auth_client.py +++ b/galaxykit/gw_auth_client.py @@ -74,11 +74,20 @@ def get_header_csfrtoken(self, session): match = re.search(token_pattern, response.text) return match.group(1) + def parse_custom_gateway_sessionid(self, cookies): + """Support gateway_sessionid cookie with optional suffix. + For example the aap-dev 2.7, the HTTP header key is gateway_sessionid44927. + """ + for cookie in cookies: + if cookie.name.startswith("gateway_sessionid"): + return cookie.name, cookie.value + return None, None + def get_cookies_from_response(self, response): self.csrftoken = response.cookies["csrftoken"] - gateway_sessionid = response.cookies["gateway_sessionid"] + custom_sessionid, gateway_sessionid = self.parse_custom_gateway_sessionid(response.cookies) return { "Accept": "application/json", - "Cookie": f"csrftoken={self.csrftoken}; gateway_sessionid={gateway_sessionid}", + "Cookie": f"csrftoken={self.csrftoken}; {custom_sessionid}={gateway_sessionid}", "X-CSRFToken": self.csrftoken, } From fe9cae49827bcedcefefd7cc779b96ffc57ab919 Mon Sep 17 00:00:00 2001 From: Jiri Jerabek Date: Tue, 7 Apr 2026 13:07:30 +0200 Subject: [PATCH 2/2] fix linter --- galaxykit/gw_auth_client.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/galaxykit/gw_auth_client.py b/galaxykit/gw_auth_client.py index b5e6908..5bbe8ae 100644 --- a/galaxykit/gw_auth_client.py +++ b/galaxykit/gw_auth_client.py @@ -75,17 +75,19 @@ def get_header_csfrtoken(self, session): return match.group(1) def parse_custom_gateway_sessionid(self, cookies): - """Support gateway_sessionid cookie with optional suffix. + """Support gateway_sessionid cookie with optional suffix. For example the aap-dev 2.7, the HTTP header key is gateway_sessionid44927. """ for cookie in cookies: - if cookie.name.startswith("gateway_sessionid"): - return cookie.name, cookie.value + if cookie.name.startswith("gateway_sessionid"): + return cookie.name, cookie.value return None, None def get_cookies_from_response(self, response): self.csrftoken = response.cookies["csrftoken"] - custom_sessionid, gateway_sessionid = self.parse_custom_gateway_sessionid(response.cookies) + custom_sessionid, gateway_sessionid = self.parse_custom_gateway_sessionid( + response.cookies + ) return { "Accept": "application/json", "Cookie": f"csrftoken={self.csrftoken}; {custom_sessionid}={gateway_sessionid}",