tesla-fleet-api 0.9.9__py3-none-any.whl → 1.0.0__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- tesla_fleet_api/__init__.py +7 -22
- tesla_fleet_api/const.py +1 -225
- tesla_fleet_api/exceptions.py +117 -0
- tesla_fleet_api/tesla/__init__.py +11 -0
- tesla_fleet_api/tesla/bluetooth.py +33 -0
- tesla_fleet_api/{charging.py → tesla/charging.py} +1 -1
- tesla_fleet_api/{energy.py → tesla/energysite.py} +41 -33
- tesla_fleet_api/{teslafleetapi.py → tesla/fleet.py} +8 -53
- tesla_fleet_api/{teslafleetoauth.py → tesla/oauth.py} +3 -4
- tesla_fleet_api/{partner.py → tesla/partner.py} +1 -1
- tesla_fleet_api/tesla/tesla.py +52 -0
- tesla_fleet_api/{user.py → tesla/user.py} +1 -1
- tesla_fleet_api/teslemetry/__init__.py +5 -0
- tesla_fleet_api/{teslemetry.py → teslemetry/teslemetry.py} +16 -25
- tesla_fleet_api/teslemetry/vehicle.py +73 -0
- tesla_fleet_api/tessie/__init__.py +5 -0
- tesla_fleet_api/{tessie.py → tessie/tessie.py} +17 -9
- tesla_fleet_api/tessie/vehicle.py +41 -0
- {tesla_fleet_api-0.9.9.dist-info → tesla_fleet_api-1.0.0.dist-info}/METADATA +3 -2
- tesla_fleet_api-1.0.0.dist-info/RECORD +24 -0
- tesla_fleet_api/energyspecific.py +0 -125
- tesla_fleet_api/pb2/__init__.py +0 -0
- tesla_fleet_api/pb2/__init__.pyi +0 -9
- tesla_fleet_api/pb2/car_server_pb2.py +0 -175
- tesla_fleet_api/pb2/car_server_pb2.pyi +0 -904
- tesla_fleet_api/pb2/common_pb2.py +0 -33
- tesla_fleet_api/pb2/common_pb2.pyi +0 -130
- tesla_fleet_api/pb2/errors_pb2.py +0 -17
- tesla_fleet_api/pb2/errors_pb2.pyi +0 -32
- tesla_fleet_api/pb2/keys_pb2.py +0 -15
- tesla_fleet_api/pb2/keys_pb2.pyi +0 -21
- tesla_fleet_api/pb2/managed_charging_pb2.py +0 -15
- tesla_fleet_api/pb2/managed_charging_pb2.pyi +0 -17
- tesla_fleet_api/pb2/signatures_pb2.py +0 -35
- tesla_fleet_api/pb2/signatures_pb2.pyi +0 -152
- tesla_fleet_api/pb2/universal_message_pb2.py +0 -30
- tesla_fleet_api/pb2/universal_message_pb2.pyi +0 -148
- tesla_fleet_api/pb2/vcsec_pb2.py +0 -79
- tesla_fleet_api/pb2/vcsec_pb2.pyi +0 -482
- tesla_fleet_api/pb2/vehicle_pb2.py +0 -125
- tesla_fleet_api/pb2/vehicle_pb2.pyi +0 -1183
- tesla_fleet_api/teslafleetopensource.py +0 -61
- tesla_fleet_api/vehicle.py +0 -878
- tesla_fleet_api/vehiclesigned.py +0 -1127
- tesla_fleet_api/vehiclespecific.py +0 -505
- tesla_fleet_api-0.9.9.dist-info/RECORD +0 -42
- {tesla_fleet_api-0.9.9.dist-info → tesla_fleet_api-1.0.0.dist-info}/LICENSE +0 -0
- {tesla_fleet_api-0.9.9.dist-info → tesla_fleet_api-1.0.0.dist-info}/WHEEL +0 -0
- {tesla_fleet_api-0.9.9.dist-info → tesla_fleet_api-1.0.0.dist-info}/top_level.txt +0 -0
@@ -1,61 +0,0 @@
|
|
1
|
-
import aiohttp
|
2
|
-
import time
|
3
|
-
import secrets
|
4
|
-
import hashlib
|
5
|
-
import base64
|
6
|
-
|
7
|
-
from .teslafleetoauth import TeslaFleetOAuth
|
8
|
-
from .const import Scope, SERVERS
|
9
|
-
|
10
|
-
|
11
|
-
class TeslaFleetOpenSource(TeslaFleetOAuth):
|
12
|
-
"""Tesla Fleet Open Source OAuth API."""
|
13
|
-
|
14
|
-
code_verifier: str
|
15
|
-
code_challenge: str
|
16
|
-
|
17
|
-
def __init__(
|
18
|
-
self,
|
19
|
-
session: aiohttp.ClientSession,
|
20
|
-
client_id: str,
|
21
|
-
redirect_uri: str,
|
22
|
-
):
|
23
|
-
self.code_verifier = secrets.token_urlsafe(32)
|
24
|
-
|
25
|
-
# Hash the code_verifier using SHA-256
|
26
|
-
hashed_verifier = hashlib.sha256(self.code_verifier.encode()).digest()
|
27
|
-
# Encode the hash using URL-safe Base64 encoding, without padding
|
28
|
-
self.code_challenge = (
|
29
|
-
base64.urlsafe_b64encode(hashed_verifier).decode().replace("=", "")
|
30
|
-
)
|
31
|
-
|
32
|
-
super().__init__(session, client_id, redirect_uri=redirect_uri)
|
33
|
-
|
34
|
-
def get_login_url(self, scopes: list[Scope], state: str = "login") -> str:
|
35
|
-
"""Get the login URL without a client secret."""
|
36
|
-
|
37
|
-
return (
|
38
|
-
super().get_login_url(scopes, state)
|
39
|
-
+ f"&code_challenge={self.code_challenge}"
|
40
|
-
)
|
41
|
-
|
42
|
-
async def get_refresh_token(self, code: str) -> None:
|
43
|
-
"""Get the refresh token."""
|
44
|
-
async with self.session.post(
|
45
|
-
"https://auth.tesla.com/oauth2/v3/token",
|
46
|
-
data={
|
47
|
-
"grant_type": "authorization_code",
|
48
|
-
"client_id": self.client_id,
|
49
|
-
"code": code,
|
50
|
-
"audience": self.server,
|
51
|
-
"redirect_uri": self.redirect_uri,
|
52
|
-
"code_verifier": self.code_verifier,
|
53
|
-
},
|
54
|
-
) as resp:
|
55
|
-
if resp.ok:
|
56
|
-
data = await resp.json()
|
57
|
-
self.refresh_token = data["refresh_token"]
|
58
|
-
self.access_token = data["access_token"]
|
59
|
-
self.expires = int(time.time()) + data["expires_in"]
|
60
|
-
region = code.split("_")[0].lower()
|
61
|
-
self.server = SERVERS.get(region)
|