aioamazondevices 6.1.0__tar.gz → 6.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {aioamazondevices-6.1.0 → aioamazondevices-6.1.2}/PKG-INFO +1 -1
- {aioamazondevices-6.1.0 → aioamazondevices-6.1.2}/pyproject.toml +1 -1
- {aioamazondevices-6.1.0 → aioamazondevices-6.1.2}/src/aioamazondevices/__init__.py +1 -1
- {aioamazondevices-6.1.0 → aioamazondevices-6.1.2}/src/aioamazondevices/api.py +16 -11
- {aioamazondevices-6.1.0 → aioamazondevices-6.1.2}/LICENSE +0 -0
- {aioamazondevices-6.1.0 → aioamazondevices-6.1.2}/README.md +0 -0
- {aioamazondevices-6.1.0 → aioamazondevices-6.1.2}/src/aioamazondevices/const.py +0 -0
- {aioamazondevices-6.1.0 → aioamazondevices-6.1.2}/src/aioamazondevices/exceptions.py +0 -0
- {aioamazondevices-6.1.0 → aioamazondevices-6.1.2}/src/aioamazondevices/py.typed +0 -0
- {aioamazondevices-6.1.0 → aioamazondevices-6.1.2}/src/aioamazondevices/query.py +0 -0
- {aioamazondevices-6.1.0 → aioamazondevices-6.1.2}/src/aioamazondevices/sounds.py +0 -0
- {aioamazondevices-6.1.0 → aioamazondevices-6.1.2}/src/aioamazondevices/utils.py +0 -0
@@ -22,7 +22,7 @@ from aiohttp import (
|
|
22
22
|
ClientSession,
|
23
23
|
)
|
24
24
|
from bs4 import BeautifulSoup, Tag
|
25
|
-
from langcodes import Language
|
25
|
+
from langcodes import Language, standardize_tag
|
26
26
|
from multidict import MultiDictProxy
|
27
27
|
from yarl import URL
|
28
28
|
|
@@ -163,7 +163,8 @@ class AmazonEchoApi:
|
|
163
163
|
lang_maximized = lang_object.maximize()
|
164
164
|
|
165
165
|
self._domain: str = domain
|
166
|
-
|
166
|
+
language = f"{lang_maximized.language}-{lang_maximized.territory}"
|
167
|
+
self._language = standardize_tag(language)
|
167
168
|
|
168
169
|
# Reset CSRF cookie when changing country
|
169
170
|
self._csrf_cookie: str | None = None
|
@@ -527,15 +528,15 @@ class AmazonEchoApi:
|
|
527
528
|
}
|
528
529
|
|
529
530
|
register_url = "https://api.amazon.com/auth/register"
|
530
|
-
_,
|
531
|
+
_, raw_resp = await self._session_request(
|
531
532
|
method=HTTPMethod.POST,
|
532
533
|
url=register_url,
|
533
534
|
input_data=body,
|
534
535
|
json_data=True,
|
535
536
|
)
|
536
|
-
resp_json = await
|
537
|
+
resp_json = await raw_resp.json()
|
537
538
|
|
538
|
-
if
|
539
|
+
if raw_resp.status != HTTPStatus.OK:
|
539
540
|
msg = resp_json["response"]["error"]["message"]
|
540
541
|
_LOGGER.error(
|
541
542
|
"Cannot register device for %s: %s",
|
@@ -543,7 +544,7 @@ class AmazonEchoApi:
|
|
543
544
|
msg,
|
544
545
|
)
|
545
546
|
raise CannotRegisterDevice(
|
546
|
-
f"{await self._http_phrase_error(
|
547
|
+
f"{await self._http_phrase_error(raw_resp.status)}: {msg}"
|
547
548
|
)
|
548
549
|
|
549
550
|
success_response = resp_json["response"]["success"]
|
@@ -703,7 +704,7 @@ class AmazonEchoApi:
|
|
703
704
|
_LOGGER.debug(
|
704
705
|
'Cannot find "auth-mfa-otpcode" in html source [%s]', login_url
|
705
706
|
)
|
706
|
-
raise CannotAuthenticate
|
707
|
+
raise CannotAuthenticate("MFA OTP code not found on login page")
|
707
708
|
|
708
709
|
login_method, login_url = self._get_request_from_soup(login_soup)
|
709
710
|
|
@@ -742,6 +743,10 @@ class AmazonEchoApi:
|
|
742
743
|
obfuscate_email(self._login_email),
|
743
744
|
)
|
744
745
|
|
746
|
+
# Check if session is still authenticated
|
747
|
+
if not await self.auth_check_status():
|
748
|
+
raise CannotAuthenticate("Session no longer authenticated")
|
749
|
+
|
745
750
|
return self._login_stored_data
|
746
751
|
|
747
752
|
async def _get_alexa_domain(self) -> str:
|
@@ -1105,21 +1110,21 @@ class AmazonEchoApi:
|
|
1105
1110
|
"domain": f"www.amazon.{self._domain}",
|
1106
1111
|
}
|
1107
1112
|
|
1108
|
-
|
1113
|
+
raw_resp = await self._session.post(
|
1109
1114
|
"https://api.amazon.com/auth/token",
|
1110
1115
|
data=data,
|
1111
1116
|
)
|
1112
1117
|
_LOGGER.debug(
|
1113
1118
|
"Refresh data response %s with payload %s",
|
1114
|
-
|
1119
|
+
raw_resp.status,
|
1115
1120
|
orjson.dumps(data),
|
1116
1121
|
)
|
1117
1122
|
|
1118
|
-
if
|
1123
|
+
if raw_resp.status != HTTPStatus.OK:
|
1119
1124
|
_LOGGER.debug("Failed to refresh data")
|
1120
1125
|
return False, {}
|
1121
1126
|
|
1122
|
-
json_response = await
|
1127
|
+
json_response = await raw_resp.json()
|
1123
1128
|
_LOGGER.debug("Refresh data json:\n%s ", json_response)
|
1124
1129
|
|
1125
1130
|
if data_type == REFRESH_ACCESS_TOKEN and (
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|