Skip to content

Commit

Permalink
Add user age to HTTP requests (#64)
Browse files Browse the repository at this point in the history
Without this server tends to reject us randomly.
  • Loading branch information
albaintor authored Dec 5, 2024
1 parent e8d5bb7 commit 35a0a54
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion toshiba_ac/utils/http_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ async def request_api(
headers = {}
headers["Content-Type"] = "application/json"
headers["Authorization"] = self.access_token_type + " " + self.access_token
headers["User-Agent"] = (
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
)

url = self.BASE_URL + path

Expand Down Expand Up @@ -114,7 +117,10 @@ async def request_api(
raise ToshibaAcHttpApiError(await response.text())

async def connect(self) -> None:
headers = {"Content-Type": "application/json"}
headers = {
"Content-Type": "application/json",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
}
post = {"Username": self.username, "Password": self.password}

res = await self.request_api(self.LOGIN_PATH, post=post, headers=headers)
Expand Down

0 comments on commit 35a0a54

Please sign in to comment.