From bbdc2b5e7a052040b973ccaa61997701a46af0bc Mon Sep 17 00:00:00 2001 From: dontinelli <73341522+dontinelli@users.noreply.github.com> Date: Mon, 30 Mar 2026 06:51:01 +0000 Subject: [PATCH 1/3] Add token to body in API request --- src/solarlog_cli/solarlog_client.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/solarlog_cli/solarlog_client.py b/src/solarlog_cli/solarlog_client.py index f5c4a75..9e049ee 100644 --- a/src/solarlog_cli/solarlog_client.py +++ b/src/solarlog_cli/solarlog_client.py @@ -41,6 +41,7 @@ def __init__(self, host: str, session: ClientSession | None, password: str = "") self._hashed_pwd: bool = False self._close_session: bool = True + self._token = "" async def test_connection(self) -> bool: """Test the connection to Solar-Log.""" @@ -113,6 +114,9 @@ async def login(self) -> bool: self.session.cookie_jar.update_cookies( {"SolarLog": response.cookies["SolarLog"].value}) + + if not self._hashed_pwd: + self._token = response.cookies["SolarLog"].value _LOGGER.debug("response: %s", text) _LOGGER.debug("cookies: %s", response.cookies) @@ -131,6 +135,9 @@ async def execute_http_request(self, body: str, path: str = "getjp", timeout: fl header = {"Content-Type": "text/html", "X-SL-CSRF-PROTECTION": "1"} + if self._token != "": + body = f"token={self._token}; " + body + _LOGGER.debug("HTTP-request header: %s", header) _LOGGER.debug("HTTP-request body: %s", body) From e4c0075305b703002fe875b255a6dd91b15a1a20 Mon Sep 17 00:00:00 2001 From: dontinelli <73341522+dontinelli@users.noreply.github.com> Date: Mon, 30 Mar 2026 06:52:57 +0000 Subject: [PATCH 2/3] update coverage --- .coverage | Bin 53248 -> 53248 bytes src/solarlog_cli/solarlog_client.py | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.coverage b/.coverage index cbd66c95cd1f94c5898d9f5964af2ae3d1ad6cbd..3476c12d936ed42da3f98ce499942f4820094634 100644 GIT binary patch delta 48 zcmV-00MGw`paX!Q1F*D@Azjy5S=~b2{{PxuU2VUs&$8`bS^xj1Ol4M9SLP{JJJqw* Gk1Ifbn;IMd delta 48 zcmV-00MGw`paX!Q1F*D@A+77ItZt!h|9|b()qYo>W!t~9{{K&z%B-xe%u}p(ssXdr Gk1If{g&ZXS diff --git a/src/solarlog_cli/solarlog_client.py b/src/solarlog_cli/solarlog_client.py index 9e049ee..5d40c80 100644 --- a/src/solarlog_cli/solarlog_client.py +++ b/src/solarlog_cli/solarlog_client.py @@ -114,7 +114,7 @@ async def login(self) -> bool: self.session.cookie_jar.update_cookies( {"SolarLog": response.cookies["SolarLog"].value}) - + if not self._hashed_pwd: self._token = response.cookies["SolarLog"].value From 832238575ca1e58568a2e88ac872c3d0d41858ee Mon Sep 17 00:00:00 2001 From: dontinelli <73341522+dontinelli@users.noreply.github.com> Date: Mon, 30 Mar 2026 08:27:13 +0000 Subject: [PATCH 3/3] add comment --- src/solarlog_cli/solarlog_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/solarlog_cli/solarlog_client.py b/src/solarlog_cli/solarlog_client.py index 5d40c80..b3549b2 100644 --- a/src/solarlog_cli/solarlog_client.py +++ b/src/solarlog_cli/solarlog_client.py @@ -41,7 +41,7 @@ def __init__(self, host: str, session: ClientSession | None, password: str = "") self._hashed_pwd: bool = False self._close_session: bool = True - self._token = "" + self._token = "" #required for older firmware, where cookie is not sufficient async def test_connection(self) -> bool: """Test the connection to Solar-Log."""