Skip to content

Commit

Permalink
Fix changed hOn login
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre0512 committed Jun 7, 2023
1 parent 31c03fa commit 3c7ad3f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
12 changes: 5 additions & 7 deletions pyhon/connection/auth.py
Expand Up @@ -134,9 +134,7 @@ async def _login_url(self, login_url: str) -> bool:
fw_uid, loaded_str = context[0]
self._login_data.fw_uid = fw_uid
self._login_data.loaded = json.loads(loaded_str)
self._login_data.url = login_url.replace(
"/".join(const.AUTH_API.split("/")[:-1]), ""
)
self._login_data.url = login_url.replace(const.AUTH_API, "")
return True
await self._error_logger(response)
return False
Expand All @@ -149,8 +147,8 @@ async def _login(self) -> str:
"descriptor": "apex://LightningLoginCustomController/ACTION$login",
"callingDescriptor": "markup://c:loginForm",
"params": {
"username": quote(self._login_data.email),
"password": quote(self._login_data.password),
"username": self._login_data.email,
"password": self._login_data.password,
"startUrl": start_url,
},
}
Expand All @@ -172,7 +170,7 @@ async def _login(self) -> str:
async with self._request.post(
const.AUTH_API + "/s/sfsites/aura",
headers={"Content-Type": "application/x-www-form-urlencoded"},
data="&".join(f"{k}={json.dumps(v)}" for k, v in data.items()),
data="&".join(f"{k}={quote(json.dumps(v))}" for k, v in data.items()),
params=params,
) as response:
if response.status == 200:
Expand Down Expand Up @@ -210,7 +208,7 @@ async def _get_token(self, url: str) -> bool:
url_search = re.findall(
"href\\s*=\\s*[\"'](.*?)[\"']", await response.text()
)
url = "/".join(const.AUTH_API.split("/")[:-1]) + url_search[0]
url = const.AUTH_API + url_search[0]
async with self._request.get(url) as response:
if response.status != 200:
await self._error_logger(response)
Expand Down
2 changes: 1 addition & 1 deletion pyhon/const.py
@@ -1,4 +1,4 @@
AUTH_API = "https://he-accounts.force.com/SmartHome"
AUTH_API = "https://account2.hon-smarthome.com"
API_URL = "https://api-iot.he.services"
API_KEY = "GRCqFhC6Gk@ikWXm1RmnSmX1cm,MxY-configuration"
APP = "hon"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -7,7 +7,7 @@

setup(
name="pyhOn",
version="0.12.0",
version="0.12.1",
author="Andre Basche",
description="Control hOn devices with python",
long_description=long_description,
Expand Down

0 comments on commit 3c7ad3f

Please sign in to comment.