From 9c66e4fe63d73cd88e663df60f15a1fc057688ba Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sun, 5 Oct 2025 11:32:38 +0200 Subject: [PATCH 1/2] Form encode on login.cgi --- CHANGELOG.md | 6 ++++++ airos/base.py | 20 ++++++++++++-------- pyproject.toml | 2 +- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2df1c9..0284e22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to this project will be documented in this file. +## [0.5.5] - 2025-10-05 + +### Changed + +- Change login from json_data to form_data for v6 login + ## [0.5.4] - 2025-10-01 ### Added diff --git a/airos/base.py b/airos/base.py index c1ae6c4..234877f 100644 --- a/airos/base.py +++ b/airos/base.py @@ -268,16 +268,20 @@ async def login(self) -> None: "POST", self._login_urls["default"], json_data=payload ) except AirOSUrlNotFoundError: - try: - await self._request_json( - "POST", self._login_urls["v6_alternative"], json_data=payload - ) - except AirOSConnectionSetupError as err: - raise AirOSConnectionSetupError( - "Failed to login to default and alternate AirOS device urls" - ) from err + pass # Try next URL except AirOSConnectionSetupError as err: raise AirOSConnectionSetupError("Failed to login to AirOS device") from err + else: + return + + try: # Alternative URL + await self._request_json( + "POST", self._login_urls["v6_alternative"], form_data=payload + ) + except AirOSConnectionSetupError as err: + raise AirOSConnectionSetupError( + "Failed to login to default and alternate AirOS device urls" + ) from err async def status(self) -> AirOSDataModel: """Retrieve status from the device.""" diff --git a/pyproject.toml b/pyproject.toml index 281e7fa..b77a7d9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "airos" -version = "0.5.4" +version = "0.5.5" license = "MIT" description = "Ubiquiti airOS module(s) for Python 3." readme = "README.md" From c9f61e65684172302e02551f3753897eaf155e6a Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sun, 5 Oct 2025 11:39:04 +0200 Subject: [PATCH 2/2] Force form content_type --- airos/base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/airos/base.py b/airos/base.py index 234877f..506917a 100644 --- a/airos/base.py +++ b/airos/base.py @@ -276,7 +276,10 @@ async def login(self) -> None: try: # Alternative URL await self._request_json( - "POST", self._login_urls["v6_alternative"], form_data=payload + "POST", + self._login_urls["v6_alternative"], + form_data=payload, + ct_form=True, ) except AirOSConnectionSetupError as err: raise AirOSConnectionSetupError(