hyundai-kia-connect-api 3.32.3__py2.py3-none-any.whl → 3.32.4__py2.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.
@@ -89,6 +89,11 @@ class ApiImpl:
89
89
  """Get cached vehicle data and update Vehicle instance with it"""
90
90
  pass
91
91
 
92
+ def test_token(self, token: Token) -> bool:
93
+ """Test if token is valid
94
+ Use any dummy request to test if token is still valid"""
95
+ return True
96
+
92
97
  def check_action_status(
93
98
  self,
94
99
  token: Token,
@@ -115,6 +115,7 @@ class KiaUvoApiCA(ApiImpl):
115
115
  url = self.API_URL + "v2/login"
116
116
  data = {"loginId": username, "password": password}
117
117
  headers = self.API_HEADERS
118
+ headers.pop("accessToken", None)
118
119
  response = self.sessions.post(url, json=data, headers=headers)
119
120
  _LOGGER.debug(f"{DOMAIN} - Sign In Response {response.text}")
120
121
  response = response.json()
@@ -135,6 +136,24 @@ class KiaUvoApiCA(ApiImpl):
135
136
  valid_until=valid_until,
136
137
  )
137
138
 
139
+ def test_token(self, token: Token) -> bool:
140
+ # Use "get number of notifications" as a dummy request to test the token
141
+ # Use this api because it's likely checked more frequently than other APIs, less
142
+ # chance to get banned. And it's short and simple.
143
+ url = self.API_URL + "ntcmsgcnt"
144
+ headers = self.API_HEADERS
145
+ headers["accessToken"] = token.access_token
146
+ response = self.sessions.post(url, headers=headers)
147
+ _LOGGER.debug(f"{DOMAIN} - Test Token Response {response.text}")
148
+ response = response.json()
149
+ token_errors = ["7403", "7602"]
150
+ if (
151
+ response["responseHeader"]["responseCode"] == 1
152
+ and response["error"]["errorCode"] in token_errors
153
+ ):
154
+ return False
155
+ return True
156
+
138
157
  def get_vehicles(self, token: Token) -> list[Vehicle]:
139
158
  url = self.API_URL + "vhcllst"
140
159
  headers = self.API_HEADERS
@@ -134,7 +134,10 @@ class VehicleManager:
134
134
  def check_and_refresh_token(self) -> bool:
135
135
  if self.token is None:
136
136
  self.initialize()
137
- if self.token.valid_until <= dt.datetime.now(pytz.utc):
137
+ if (
138
+ self.token.valid_until <= dt.datetime.now(pytz.utc)
139
+ or self.api.test_token(self.token) is False
140
+ ):
138
141
  _LOGGER.debug(f"{DOMAIN} - Refresh token expired")
139
142
  self.token: Token = self.api.login(self.username, self.password)
140
143
  self.token.pin = self.pin
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: hyundai_kia_connect_api
3
- Version: 3.32.3
3
+ Version: 3.32.4
4
4
  Summary: Python Boilerplate contains all the boilerplate you need to create a Python package.
5
5
  Home-page: https://github.com/Hyundai-Kia-Connect/hyundai_kia_connect_api
6
6
  Author: Fuat Akgun
@@ -1,23 +1,23 @@
1
- hyundai_kia_connect_api/ApiImpl.py,sha256=eCEQEz6L-7EN2eKnrYiHrYC0pPV-ngGFcayF0tFdPxA,7569
1
+ hyundai_kia_connect_api/ApiImpl.py,sha256=mZO8AT-MBMBFspB7sZ2MkK_uxbbJ59J3rM_uJmU4-fE,7737
2
2
  hyundai_kia_connect_api/ApiImplType1.py,sha256=PnKwpbCoYGOXBWzBLIlDSrC6daIYeW9qlfW7TM4HCU0,12184
3
3
  hyundai_kia_connect_api/HyundaiBlueLinkApiUSA.py,sha256=Tx-L4ZWiPhq-uHcjWSUzjLEsfunV6nzyzqQpjPTYuIo,36831
4
4
  hyundai_kia_connect_api/KiaUvoApiAU.py,sha256=tslh0gzvPBwYJmcWlf9B0l7PyYZdy2e7GqpRkl8_Svk,48471
5
- hyundai_kia_connect_api/KiaUvoApiCA.py,sha256=uANAbsqG-ywLxIWLPPzcsougiRL8hho9gzg2kxErgT8,30874
5
+ hyundai_kia_connect_api/KiaUvoApiCA.py,sha256=uAAsKwXk8E-1HsLuOYBDb1cowHo2Qfgn6Cmf5fmP-UM,31721
6
6
  hyundai_kia_connect_api/KiaUvoApiCN.py,sha256=cwIPZ0dU6HolKdooUQeQKlLAic6YU8dQmNs0VQDBgpQ,47035
7
7
  hyundai_kia_connect_api/KiaUvoApiEU.py,sha256=TxgO2dfLjKSKfSkRMoTL_fbmzRFRPb8oJ9IDztD50Ug,71300
8
8
  hyundai_kia_connect_api/KiaUvoApiUSA.py,sha256=G2sGtv88sBZuAz8qKYq_3_JNXIkxEjOBAzwM6R8GUi0,30548
9
9
  hyundai_kia_connect_api/Token.py,sha256=ZsPvXh1ID7FUTGHAqhZUZyrKT7xVbOtIn6FRJn4Ygf0,370
10
10
  hyundai_kia_connect_api/Vehicle.py,sha256=raCMzJsLuJnVHlFJ16VKdKat55L0uivbbcZRDCGWTxI,18793
11
- hyundai_kia_connect_api/VehicleManager.py,sha256=I0HDOsbXDen-26vyD7YR-RUgdaofOZrv_H_PPPuWjHg,11087
11
+ hyundai_kia_connect_api/VehicleManager.py,sha256=SfGuCT0foCJqUNNLXs_9lRR5XGQ7xd-fodTIs3JEl0o,11167
12
12
  hyundai_kia_connect_api/__init__.py,sha256=IkyVeIMbcFJZgLaiiNnUVA1Ferxvrm1bXHKVg01cxvc,319
13
13
  hyundai_kia_connect_api/bluelink.py,sha256=sBU7hlElie21GU4Ma-i4a5vdztGc2jtmlVBbbgUqmTE,19720
14
14
  hyundai_kia_connect_api/const.py,sha256=scBlhrMims0W6_pESVVdQz2uUxczg2cf2qDQ7avbhVo,2174
15
15
  hyundai_kia_connect_api/exceptions.py,sha256=m7gyDnvA5OVAK4EXSP_ZwE0s0uV8HsGUV0tiYwqofK0,1343
16
16
  hyundai_kia_connect_api/utils.py,sha256=J0aXUX-nKIoS3XbelatNh-DZlHRU2_DYz_Mg_ZUKQJU,1957
17
- hyundai_kia_connect_api-3.32.3.dist-info/AUTHORS.rst,sha256=T77OE1hrQF6YyDE6NbdMKyL66inHt7dnjHAzblwuk2A,155
18
- hyundai_kia_connect_api-3.32.3.dist-info/LICENSE,sha256=49hmc755oyMwKdZ-2epiorjStRB0PfcZR1w5_NXZPgs,1068
19
- hyundai_kia_connect_api-3.32.3.dist-info/METADATA,sha256=E1v9297ptlZ8mATwHUzP88PdwPQZ3OHXGMxT2t7E1jk,6872
20
- hyundai_kia_connect_api-3.32.3.dist-info/WHEEL,sha256=9Hm2OB-j1QcCUq9Jguht7ayGIIZBRTdOXD1qg9cCgPM,109
21
- hyundai_kia_connect_api-3.32.3.dist-info/entry_points.txt,sha256=XfrroRdyC_9q9VXjEZe5SdRPhkQyCCE4S7ZK6XSKelA,67
22
- hyundai_kia_connect_api-3.32.3.dist-info/top_level.txt,sha256=otZ7J_fN-s3EW4jD-kAearIo2OIzhQLR8DNEHIaFfds,24
23
- hyundai_kia_connect_api-3.32.3.dist-info/RECORD,,
17
+ hyundai_kia_connect_api-3.32.4.dist-info/AUTHORS.rst,sha256=T77OE1hrQF6YyDE6NbdMKyL66inHt7dnjHAzblwuk2A,155
18
+ hyundai_kia_connect_api-3.32.4.dist-info/LICENSE,sha256=49hmc755oyMwKdZ-2epiorjStRB0PfcZR1w5_NXZPgs,1068
19
+ hyundai_kia_connect_api-3.32.4.dist-info/METADATA,sha256=td3I1luOoCaSb-4YKnw38X65K0ro0IP1vhdXs7WPEhY,6872
20
+ hyundai_kia_connect_api-3.32.4.dist-info/WHEEL,sha256=9Hm2OB-j1QcCUq9Jguht7ayGIIZBRTdOXD1qg9cCgPM,109
21
+ hyundai_kia_connect_api-3.32.4.dist-info/entry_points.txt,sha256=XfrroRdyC_9q9VXjEZe5SdRPhkQyCCE4S7ZK6XSKelA,67
22
+ hyundai_kia_connect_api-3.32.4.dist-info/top_level.txt,sha256=otZ7J_fN-s3EW4jD-kAearIo2OIzhQLR8DNEHIaFfds,24
23
+ hyundai_kia_connect_api-3.32.4.dist-info/RECORD,,