python-chargepoint 2.3.1__tar.gz → 2.4.0__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.
- {python_chargepoint-2.3.1 → python_chargepoint-2.4.0}/PKG-INFO +2 -1
- {python_chargepoint-2.3.1 → python_chargepoint-2.4.0}/pyproject.toml +2 -2
- {python_chargepoint-2.3.1 → python_chargepoint-2.4.0}/python_chargepoint/__main__.py +0 -1
- {python_chargepoint-2.3.1 → python_chargepoint-2.4.0}/python_chargepoint/client.py +15 -4
- {python_chargepoint-2.3.1 → python_chargepoint-2.4.0}/LICENSE +0 -0
- {python_chargepoint-2.3.1 → python_chargepoint-2.4.0}/README.md +0 -0
- {python_chargepoint-2.3.1 → python_chargepoint-2.4.0}/python_chargepoint/__init__.py +0 -0
- {python_chargepoint-2.3.1 → python_chargepoint-2.4.0}/python_chargepoint/constants.py +0 -0
- {python_chargepoint-2.3.1 → python_chargepoint-2.4.0}/python_chargepoint/exceptions.py +0 -0
- {python_chargepoint-2.3.1 → python_chargepoint-2.4.0}/python_chargepoint/global_config.py +0 -0
- {python_chargepoint-2.3.1 → python_chargepoint-2.4.0}/python_chargepoint/session.py +0 -0
- {python_chargepoint-2.3.1 → python_chargepoint-2.4.0}/python_chargepoint/types.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-chargepoint
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.4.0
|
|
4
4
|
Summary: A simple, Pythonic wrapper for the ChargePoint API.
|
|
5
5
|
License: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -14,6 +14,7 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.12
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.13
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
17
18
|
Requires-Dist: aiohttp (>=3.9,<4.0)
|
|
18
19
|
Requires-Dist: click (>=8.1,<9.0)
|
|
19
20
|
Requires-Dist: pydantic (>=2.12,<3.0)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "python-chargepoint"
|
|
3
|
-
version = "2.
|
|
3
|
+
version = "2.4.0"
|
|
4
4
|
description = "A simple, Pythonic wrapper for the ChargePoint API."
|
|
5
5
|
authors = ["Marc Billow <mbillow@users.noreply.github.compoetry>"]
|
|
6
6
|
license = "MIT"
|
|
@@ -20,7 +20,7 @@ chargepoint = "python_chargepoint.__main__:cli"
|
|
|
20
20
|
|
|
21
21
|
[tool.poetry.group.dev.dependencies]
|
|
22
22
|
tox = "^3.24.5"
|
|
23
|
-
black = "^
|
|
23
|
+
black = "^26.1.0"
|
|
24
24
|
pytest = "^7.0"
|
|
25
25
|
aioresponses = "^0.7"
|
|
26
26
|
pytest-asyncio = "^0.23"
|
|
@@ -13,7 +13,6 @@ from .constants import _LOGGER
|
|
|
13
13
|
from .exceptions import CommunicationError, InvalidSession, LoginError
|
|
14
14
|
from .types import MapFilter, ZoomBounds
|
|
15
15
|
|
|
16
|
-
|
|
17
16
|
# ---------------------------------------------------------------------------
|
|
18
17
|
# Helpers
|
|
19
18
|
# ---------------------------------------------------------------------------
|
|
@@ -41,6 +41,7 @@ USER_AGENT = f"{MODULE_NAME}/{MODULE_VERSION}"
|
|
|
41
41
|
COULOMB_SESSION = "coulomb_sess"
|
|
42
42
|
SSO_SESSION = "auth-session"
|
|
43
43
|
COOKIE_DOMAIN = ".chargepoint.com"
|
|
44
|
+
_COULOMB_SESSION_MAX_AGE = 10 * 365 * 24 * 3600
|
|
44
45
|
|
|
45
46
|
|
|
46
47
|
def _require_login(func):
|
|
@@ -60,11 +61,13 @@ class ChargePoint:
|
|
|
60
61
|
username: str,
|
|
61
62
|
coulomb_token: str = "",
|
|
62
63
|
session: Optional[aiohttp.ClientSession] = None,
|
|
64
|
+
user_agent: Optional[str] = None,
|
|
63
65
|
):
|
|
64
66
|
self._username = username
|
|
65
67
|
self._user_id: Optional[int] = None
|
|
66
68
|
self._global_config: GlobalConfiguration
|
|
67
|
-
self.
|
|
69
|
+
self._user_agent = user_agent or USER_AGENT
|
|
70
|
+
self._request_headers = {"user-agent": self._user_agent}
|
|
68
71
|
self._owns_session = session is None
|
|
69
72
|
|
|
70
73
|
if session is not None:
|
|
@@ -81,8 +84,9 @@ class ChargePoint:
|
|
|
81
84
|
username: str,
|
|
82
85
|
coulomb_token: str = "",
|
|
83
86
|
session: Optional[aiohttp.ClientSession] = None,
|
|
87
|
+
user_agent: Optional[str] = None,
|
|
84
88
|
) -> ChargePoint:
|
|
85
|
-
client = cls(username, coulomb_token, session)
|
|
89
|
+
client = cls(username, coulomb_token, session, user_agent)
|
|
86
90
|
client._global_config = await client._get_configuration(username)
|
|
87
91
|
if coulomb_token:
|
|
88
92
|
await client._init_account_parameters()
|
|
@@ -115,6 +119,7 @@ class ChargePoint:
|
|
|
115
119
|
cookie[COULOMB_SESSION] = parsed
|
|
116
120
|
cookie[COULOMB_SESSION]["domain"] = COOKIE_DOMAIN
|
|
117
121
|
cookie[COULOMB_SESSION]["path"] = "/"
|
|
122
|
+
cookie[COULOMB_SESSION]["max-age"] = str(_COULOMB_SESSION_MAX_AGE)
|
|
118
123
|
self._session.cookie_jar.update_cookies(
|
|
119
124
|
cookie, response_url=URL(f"https://account{COOKIE_DOMAIN}/")
|
|
120
125
|
)
|
|
@@ -202,7 +207,9 @@ class ChargePoint:
|
|
|
202
207
|
_LOGGER.debug(
|
|
203
208
|
"Attempting client login (%s) with user: %s", login_url, self._username
|
|
204
209
|
)
|
|
205
|
-
async with self._session.post(
|
|
210
|
+
async with self._session.post(
|
|
211
|
+
login_url, json=request, headers={"user-agent": self._user_agent}
|
|
212
|
+
) as login:
|
|
206
213
|
cookie_morsel = login.cookies.get(COULOMB_SESSION)
|
|
207
214
|
if login.status == 200 and cookie_morsel:
|
|
208
215
|
self._set_coulomb_token(cookie_morsel.value)
|
|
@@ -234,7 +241,11 @@ class ChargePoint:
|
|
|
234
241
|
self._global_config.endpoints.portal_domain_endpoint
|
|
235
242
|
/ "index.php/nghelper/getSession"
|
|
236
243
|
)
|
|
237
|
-
async with self._session.get(
|
|
244
|
+
async with self._session.get(
|
|
245
|
+
url,
|
|
246
|
+
cookies={SSO_SESSION: sso_jwt},
|
|
247
|
+
headers={"user-agent": self._user_agent},
|
|
248
|
+
) as response:
|
|
238
249
|
cookie_morsel = response.cookies.get(COULOMB_SESSION)
|
|
239
250
|
if response.status == 200 and cookie_morsel:
|
|
240
251
|
self._set_coulomb_token(cookie_morsel.value)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|