hyundai-kia-connect-api 3.32.2__tar.gz → 3.32.4__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.
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/PKG-INFO +1 -1
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/hyundai_kia_connect_api/ApiImpl.py +5 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/hyundai_kia_connect_api/KiaUvoApiCA.py +21 -20
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/hyundai_kia_connect_api/VehicleManager.py +4 -1
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/hyundai_kia_connect_api.egg-info/PKG-INFO +1 -1
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/setup.py +1 -1
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/AUTHORS.rst +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/CONTRIBUTING.rst +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/HISTORY.rst +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/LICENSE +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/MANIFEST.in +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/README.rst +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/docs/Makefile +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/docs/authors.rst +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/docs/conf.py +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/docs/contributing.rst +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/docs/history.rst +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/docs/index.rst +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/docs/installation.rst +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/docs/make.bat +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/docs/readme.rst +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/docs/usage.rst +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/hyundai_kia_connect_api/ApiImplType1.py +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/hyundai_kia_connect_api/HyundaiBlueLinkApiUSA.py +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/hyundai_kia_connect_api/KiaUvoApiAU.py +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/hyundai_kia_connect_api/KiaUvoApiCN.py +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/hyundai_kia_connect_api/KiaUvoApiEU.py +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/hyundai_kia_connect_api/KiaUvoApiUSA.py +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/hyundai_kia_connect_api/Token.py +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/hyundai_kia_connect_api/Vehicle.py +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/hyundai_kia_connect_api/__init__.py +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/hyundai_kia_connect_api/bluelink.py +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/hyundai_kia_connect_api/const.py +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/hyundai_kia_connect_api/exceptions.py +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/hyundai_kia_connect_api/utils.py +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/hyundai_kia_connect_api.egg-info/SOURCES.txt +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/hyundai_kia_connect_api.egg-info/dependency_links.txt +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/hyundai_kia_connect_api.egg-info/entry_points.txt +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/hyundai_kia_connect_api.egg-info/not-zip-safe +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/hyundai_kia_connect_api.egg-info/requires.txt +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/hyundai_kia_connect_api.egg-info/top_level.txt +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/requirements.txt +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/setup.cfg +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/tests/__init__.py +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/tests/au_login_test.py +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/tests/ca_login_test.py +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/tests/eu_check_response_for_errors_test.py +0 -0
- {hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/tests/eu_login_test.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: hyundai_kia_connect_api
|
3
|
-
Version: 3.32.
|
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
|
{hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/hyundai_kia_connect_api/ApiImpl.py
RENAMED
@@ -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,
|
@@ -6,7 +6,6 @@ import time
|
|
6
6
|
import datetime as dt
|
7
7
|
import json
|
8
8
|
import logging
|
9
|
-
|
10
9
|
import pytz
|
11
10
|
import requests
|
12
11
|
|
@@ -38,28 +37,12 @@ from .utils import (
|
|
38
37
|
parse_datetime,
|
39
38
|
)
|
40
39
|
|
41
|
-
import ssl
|
42
|
-
import urllib3
|
43
40
|
|
44
41
|
CIPHERS = "ALL:@SECLEVEL=0"
|
45
42
|
|
46
43
|
_LOGGER = logging.getLogger(__name__)
|
47
44
|
|
48
45
|
|
49
|
-
class cipherAdapter(requests.adapters.HTTPAdapter):
|
50
|
-
"""
|
51
|
-
A HTTPAdapter that re-enables poor ciphers required by Hyundai.
|
52
|
-
"""
|
53
|
-
|
54
|
-
def init_poolmanager(self, connections, maxsize, block=False):
|
55
|
-
context = ssl.create_default_context()
|
56
|
-
context.set_ciphers(CIPHERS)
|
57
|
-
context.options |= getattr(ssl, "OP_LEGACY_SERVER_CONNECT", 0x4)
|
58
|
-
self.poolmanager = urllib3.poolmanager.PoolManager(
|
59
|
-
ssl_version=ssl.PROTOCOL_TLS, ssl_context=context
|
60
|
-
)
|
61
|
-
|
62
|
-
|
63
46
|
class KiaUvoApiCA(ApiImpl):
|
64
47
|
"""KiaUvoApiCA"""
|
65
48
|
|
@@ -89,7 +72,7 @@ class KiaUvoApiCA(ApiImpl):
|
|
89
72
|
"host": self.BASE_URL,
|
90
73
|
"origin": "https://" + self.BASE_URL,
|
91
74
|
"referer": "https://" + self.BASE_URL + "/login",
|
92
|
-
"from": "
|
75
|
+
"from": "CWP",
|
93
76
|
"language": "0",
|
94
77
|
"offset": "0",
|
95
78
|
"sec-fetch-dest": "empty",
|
@@ -102,7 +85,6 @@ class KiaUvoApiCA(ApiImpl):
|
|
102
85
|
def sessions(self):
|
103
86
|
if not self._sessions:
|
104
87
|
self._sessions = requests.Session()
|
105
|
-
self._sessions.mount("https://" + self.BASE_URL, cipherAdapter())
|
106
88
|
return self._sessions
|
107
89
|
|
108
90
|
def _check_response_for_errors(self, response: dict) -> None:
|
@@ -133,11 +115,12 @@ class KiaUvoApiCA(ApiImpl):
|
|
133
115
|
url = self.API_URL + "v2/login"
|
134
116
|
data = {"loginId": username, "password": password}
|
135
117
|
headers = self.API_HEADERS
|
118
|
+
headers.pop("accessToken", None)
|
136
119
|
response = self.sessions.post(url, json=data, headers=headers)
|
137
120
|
_LOGGER.debug(f"{DOMAIN} - Sign In Response {response.text}")
|
138
121
|
response = response.json()
|
139
122
|
self._check_response_for_errors(response)
|
140
|
-
response = response["result"]
|
123
|
+
response = response["result"]["token"]
|
141
124
|
access_token = response["accessToken"]
|
142
125
|
refresh_token = response["refreshToken"]
|
143
126
|
_LOGGER.debug(f"{DOMAIN} - Access Token Value {access_token}")
|
@@ -153,6 +136,24 @@ class KiaUvoApiCA(ApiImpl):
|
|
153
136
|
valid_until=valid_until,
|
154
137
|
)
|
155
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
|
+
|
156
157
|
def get_vehicles(self, token: Token) -> list[Vehicle]:
|
157
158
|
url = self.API_URL + "vhcllst"
|
158
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
|
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
|
+
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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/hyundai_kia_connect_api/Token.py
RENAMED
File without changes
|
{hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/hyundai_kia_connect_api/Vehicle.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/hyundai_kia_connect_api/const.py
RENAMED
File without changes
|
File without changes
|
{hyundai_kia_connect_api-3.32.2 → hyundai_kia_connect_api-3.32.4}/hyundai_kia_connect_api/utils.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|