tesla-fleet-api 1.1.1__py3-none-any.whl → 1.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.
- tesla_fleet_api/__init__.py +1 -1
- tesla_fleet_api/tesla/fleet.py +47 -4
- {tesla_fleet_api-1.1.1.dist-info → tesla_fleet_api-1.1.2.dist-info}/METADATA +1 -1
- {tesla_fleet_api-1.1.1.dist-info → tesla_fleet_api-1.1.2.dist-info}/RECORD +7 -7
- {tesla_fleet_api-1.1.1.dist-info → tesla_fleet_api-1.1.2.dist-info}/WHEEL +0 -0
- {tesla_fleet_api-1.1.1.dist-info → tesla_fleet_api-1.1.2.dist-info}/licenses/LICENSE +0 -0
- {tesla_fleet_api-1.1.1.dist-info → tesla_fleet_api-1.1.2.dist-info}/top_level.txt +0 -0
tesla_fleet_api/__init__.py
CHANGED
tesla_fleet_api/tesla/fleet.py
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
"""Tesla Fleet API for Python."""
|
2
2
|
|
3
3
|
from json import dumps
|
4
|
-
from typing import Any, Awaitable
|
4
|
+
from typing import Any, Awaitable, Callable
|
5
5
|
import aiohttp
|
6
6
|
|
7
7
|
from tesla_fleet_api.tesla.tesla import Tesla
|
8
8
|
from tesla_fleet_api.exceptions import raise_for_status, InvalidRegion, LibraryError, ResponseError
|
9
|
-
from tesla_fleet_api.const import SERVERS, Method, LOGGER
|
9
|
+
from tesla_fleet_api.const import SERVERS, Method, LOGGER, Scope
|
10
10
|
from tesla_fleet_api import __version__ as VERSION
|
11
11
|
|
12
12
|
# Based on https://developer.tesla.com/docs/fleet-api
|
@@ -18,7 +18,7 @@ class TeslaFleetApi(Tesla):
|
|
18
18
|
server: str | None = None
|
19
19
|
session: aiohttp.ClientSession
|
20
20
|
headers: dict[str, str]
|
21
|
-
refresh_hook: Awaitable | None = None
|
21
|
+
refresh_hook: Callable[[], Awaitable[str | None]] | None = None
|
22
22
|
|
23
23
|
def __init__(
|
24
24
|
self,
|
@@ -31,7 +31,7 @@ class TeslaFleetApi(Tesla):
|
|
31
31
|
partner_scope: bool = True,
|
32
32
|
user_scope: bool = True,
|
33
33
|
vehicle_scope: bool = True,
|
34
|
-
refresh_hook: Awaitable | None = None,
|
34
|
+
refresh_hook: Callable[[], Awaitable[str | None]] | None = None,
|
35
35
|
):
|
36
36
|
"""Initialize the Tesla Fleet API."""
|
37
37
|
|
@@ -149,3 +149,46 @@ class TeslaFleetApi(Tesla):
|
|
149
149
|
Method.GET,
|
150
150
|
"api/1/products",
|
151
151
|
)
|
152
|
+
|
153
|
+
async def partner_login(
|
154
|
+
self,
|
155
|
+
client_id: str,
|
156
|
+
client_secret: str,
|
157
|
+
scopes: list[Scope] = [Scope.VEHICLE_DEVICE_DATA],
|
158
|
+
) -> dict[str, Any]:
|
159
|
+
"""Generate a partner token using client credentials authentication.
|
160
|
+
|
161
|
+
Args:
|
162
|
+
client_id: Partner application client ID
|
163
|
+
client_secret: Partner application client secret
|
164
|
+
scopes: Optional list of scopes to request
|
165
|
+
|
166
|
+
Returns:
|
167
|
+
Dictionary containing access token and token metadata
|
168
|
+
"""
|
169
|
+
|
170
|
+
# Throw if there is no server set
|
171
|
+
if not self.server:
|
172
|
+
raise ValueError("Server was not set at init. Call find_server() first.")
|
173
|
+
|
174
|
+
data = {
|
175
|
+
"grant_type": "client_credentials",
|
176
|
+
"client_id": client_id,
|
177
|
+
"client_secret": client_secret,
|
178
|
+
"audience": self.server,
|
179
|
+
"scope": " ".join(scopes),
|
180
|
+
}
|
181
|
+
|
182
|
+
async with self.session.post(
|
183
|
+
"https://fleet-auth.prd.vn.cloud.tesla.com/oauth2/v3/token",
|
184
|
+
headers={"Content-Type": "application/x-www-form-urlencoded"},
|
185
|
+
data=data,
|
186
|
+
) as resp:
|
187
|
+
if resp.ok:
|
188
|
+
token_data = await resp.json()
|
189
|
+
# Set the access token for subsequent API calls
|
190
|
+
self.access_token = token_data["access_token"]
|
191
|
+
return token_data
|
192
|
+
else:
|
193
|
+
error_data = await resp.json()
|
194
|
+
raise ValueError(f"Partner login failed: {error_data}")
|
@@ -1,11 +1,11 @@
|
|
1
|
-
tesla_fleet_api/__init__.py,sha256=
|
1
|
+
tesla_fleet_api/__init__.py,sha256=t-BqZ0c4wwHij5mso0aYIOxsw0ZtocyXq7P2s-suPo0,474
|
2
2
|
tesla_fleet_api/const.py,sha256=cu9jvvFTLOw56bL78lIPWJKlb35T9CYACI5pBT6DBQI,3881
|
3
3
|
tesla_fleet_api/exceptions.py,sha256=39O76jiybiAQSjfVnp4KMJz7z9TP1WYBZ1zovN_Aock,36435
|
4
4
|
tesla_fleet_api/tesla/__init__.py,sha256=ahqqQigZbXfysOpo28qUudUfWrQfKRpD_1az368Sjr0,823
|
5
5
|
tesla_fleet_api/tesla/bluetooth.py,sha256=lyPRVf1YdcElrYBsKOMCaLwMPE9rO7Iw1a6nE7VUZ94,2369
|
6
6
|
tesla_fleet_api/tesla/charging.py,sha256=D7I7cAf-3-95sIjyP6wpVqCq9Cppj6U-VPFQGpQQ8bs,1704
|
7
7
|
tesla_fleet_api/tesla/energysite.py,sha256=vStffklBQfQNAO_1wrHLFu7BlBCTVVbLh7_IrAUL3wg,6131
|
8
|
-
tesla_fleet_api/tesla/fleet.py,sha256=
|
8
|
+
tesla_fleet_api/tesla/fleet.py,sha256=nFTatXH-X3ikRQDh0BKjPST3Wb6qEDC_dGBz_WZ8wm8,7022
|
9
9
|
tesla_fleet_api/tesla/oauth.py,sha256=aWBsWmnM-QxzaU8W9TXVNxGsYn_LraXnpexwdE8wOqo,4104
|
10
10
|
tesla_fleet_api/tesla/partner.py,sha256=e-l6sEP6-IupjFEQieSUjhhvRXF3aL4ebPNahcGFRCE,1238
|
11
11
|
tesla_fleet_api/tesla/tesla.py,sha256=Gs8-L3OsEMhs1N_vdDx-E46bOHKGowXTBxmRiP8NKh4,2391
|
@@ -43,8 +43,8 @@ tesla_fleet_api/teslemetry/vehicles.py,sha256=IJMRKb3jrW9ZSdJrCQ5wOYYZGVbFvSVza2
|
|
43
43
|
tesla_fleet_api/tessie/__init__.py,sha256=8HiaMLz1RueRoT5PSF1Y7iRr0-RV6ujgOH2RBSSUFk4,436
|
44
44
|
tesla_fleet_api/tessie/tessie.py,sha256=UByX0BmDcqLPiW8ofNuGmMcjXvaWRn3taC68Ji80Yf8,2666
|
45
45
|
tesla_fleet_api/tessie/vehicles.py,sha256=Cdp0pt2Z8bzK5T9wQ8_KubGSZ3Gevx1Q18kqJqEUxfs,1011
|
46
|
-
tesla_fleet_api-1.1.
|
47
|
-
tesla_fleet_api-1.1.
|
48
|
-
tesla_fleet_api-1.1.
|
49
|
-
tesla_fleet_api-1.1.
|
50
|
-
tesla_fleet_api-1.1.
|
46
|
+
tesla_fleet_api-1.1.2.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
47
|
+
tesla_fleet_api-1.1.2.dist-info/METADATA,sha256=_z8L0X3k6n68mqUouDtSMFTFOy8wW1tmAtsiFbLmF4o,6720
|
48
|
+
tesla_fleet_api-1.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
49
|
+
tesla_fleet_api-1.1.2.dist-info/top_level.txt,sha256=jeNbog_1saXBFrGpom9WyPWmilxsyP3szL_G7JLWQfM,16
|
50
|
+
tesla_fleet_api-1.1.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|