aioamazondevices 6.1.1__py3-none-any.whl → 6.1.2__py3-none-any.whl

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.
@@ -1,6 +1,6 @@
1
1
  """aioamazondevices library."""
2
2
 
3
- __version__ = "6.1.1"
3
+ __version__ = "6.1.2"
4
4
 
5
5
 
6
6
  from .api import AmazonDevice, AmazonEchoApi
aioamazondevices/api.py CHANGED
@@ -528,15 +528,15 @@ class AmazonEchoApi:
528
528
  }
529
529
 
530
530
  register_url = "https://api.amazon.com/auth/register"
531
- _, resp = await self._session_request(
531
+ _, raw_resp = await self._session_request(
532
532
  method=HTTPMethod.POST,
533
533
  url=register_url,
534
534
  input_data=body,
535
535
  json_data=True,
536
536
  )
537
- resp_json = await resp.json()
537
+ resp_json = await raw_resp.json()
538
538
 
539
- if resp.status != HTTPStatus.OK:
539
+ if raw_resp.status != HTTPStatus.OK:
540
540
  msg = resp_json["response"]["error"]["message"]
541
541
  _LOGGER.error(
542
542
  "Cannot register device for %s: %s",
@@ -544,7 +544,7 @@ class AmazonEchoApi:
544
544
  msg,
545
545
  )
546
546
  raise CannotRegisterDevice(
547
- f"{await self._http_phrase_error(resp.status)}: {msg}"
547
+ f"{await self._http_phrase_error(raw_resp.status)}: {msg}"
548
548
  )
549
549
 
550
550
  success_response = resp_json["response"]["success"]
@@ -704,7 +704,7 @@ class AmazonEchoApi:
704
704
  _LOGGER.debug(
705
705
  'Cannot find "auth-mfa-otpcode" in html source [%s]', login_url
706
706
  )
707
- raise CannotAuthenticate
707
+ raise CannotAuthenticate("MFA OTP code not found on login page")
708
708
 
709
709
  login_method, login_url = self._get_request_from_soup(login_soup)
710
710
 
@@ -743,6 +743,10 @@ class AmazonEchoApi:
743
743
  obfuscate_email(self._login_email),
744
744
  )
745
745
 
746
+ # Check if session is still authenticated
747
+ if not await self.auth_check_status():
748
+ raise CannotAuthenticate("Session no longer authenticated")
749
+
746
750
  return self._login_stored_data
747
751
 
748
752
  async def _get_alexa_domain(self) -> str:
@@ -1106,21 +1110,21 @@ class AmazonEchoApi:
1106
1110
  "domain": f"www.amazon.{self._domain}",
1107
1111
  }
1108
1112
 
1109
- response = await self._session.post(
1113
+ raw_resp = await self._session.post(
1110
1114
  "https://api.amazon.com/auth/token",
1111
1115
  data=data,
1112
1116
  )
1113
1117
  _LOGGER.debug(
1114
1118
  "Refresh data response %s with payload %s",
1115
- response.status,
1119
+ raw_resp.status,
1116
1120
  orjson.dumps(data),
1117
1121
  )
1118
1122
 
1119
- if response.status != HTTPStatus.OK:
1123
+ if raw_resp.status != HTTPStatus.OK:
1120
1124
  _LOGGER.debug("Failed to refresh data")
1121
1125
  return False, {}
1122
1126
 
1123
- json_response = await response.json()
1127
+ json_response = await raw_resp.json()
1124
1128
  _LOGGER.debug("Refresh data json:\n%s ", json_response)
1125
1129
 
1126
1130
  if data_type == REFRESH_ACCESS_TOKEN and (
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: aioamazondevices
3
- Version: 6.1.1
3
+ Version: 6.1.2
4
4
  Summary: Python library to control Amazon devices
5
5
  License: Apache-2.0
6
6
  Author: Simone Chemelli
@@ -1,12 +1,12 @@
1
- aioamazondevices/__init__.py,sha256=MClC2ozQ757Uf3LM3AnbaSMGc47eUbVRdIAQc0fbT8w,276
2
- aioamazondevices/api.py,sha256=oeRI_ZhsEaaSh2iXFbqTgAbTq-VrJ1jW7C11cXpYHss,40721
1
+ aioamazondevices/__init__.py,sha256=E44EI2JWNaxJUHaUZZIdgRkO7_5H3ArkUwG6zQ4vuss,276
2
+ aioamazondevices/api.py,sha256=43jaKpbMXNMsyR4iIvIW0FESlj7OhJMhaxcbLVFvvu0,40947
3
3
  aioamazondevices/const.py,sha256=bqJmaStichdm0zB1RQYXa4OPz2gU2JnmUFQHeItlnZE,10808
4
4
  aioamazondevices/exceptions.py,sha256=JDnSFi_7oEhqK31sHXf0S_cyMoMjiRJuLp4ow7mYgLY,643
5
5
  aioamazondevices/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  aioamazondevices/query.py,sha256=AGHHzefzfYzB7RLWPtlFxYc_rpUZdoeApsU2jYz3urQ,2053
7
7
  aioamazondevices/sounds.py,sha256=CXMDk-KoKVFxBdVAw3MeOClqgpzcVDxvQhFOJp7qX-Y,1896
8
8
  aioamazondevices/utils.py,sha256=RzuKRhnq_8ymCoJMoQJ2vBYyuew06RSWpqQWmqdNczE,2019
9
- aioamazondevices-6.1.1.dist-info/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
10
- aioamazondevices-6.1.1.dist-info/METADATA,sha256=fWju3izz8YjDYtWqj2CHHTHSC-YjmWWD8DHTIi4wKO8,7623
11
- aioamazondevices-6.1.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
12
- aioamazondevices-6.1.1.dist-info/RECORD,,
9
+ aioamazondevices-6.1.2.dist-info/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
10
+ aioamazondevices-6.1.2.dist-info/METADATA,sha256=CbbSegxCc24kR6kxciv61wBy4-ihMj5Rdbw0T6c-va0,7623
11
+ aioamazondevices-6.1.2.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
12
+ aioamazondevices-6.1.2.dist-info/RECORD,,