You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TeslaPy 2.1.0+ no longer implements [RFC 7523](https://tools.ietf.org/html/rfc7523) and uses the SSO token for all API requests.
38
41
@@ -43,9 +46,11 @@ The convenience method `api()` uses named endpoints listed in *endpoints.json* t
43
46
| Call | Description |
44
47
| --- | --- |
45
48
|`request()`| performs API call using relative or absolute URL, serialization and error message handling |
46
-
|`authorization_url()`| forms authorization URL with [PKCE](https://oauth.net/2/pkce/) extension |
49
+
|`new_code_verifier()`| generates code verifier for [PKCE](https://oauth.net/2/pkce/)|
50
+
|`authorization_url()`| forms authorization URL with [PKCE](https://oauth.net/2/pkce/) extension and tries to detect the accounts registered region |
47
51
|`fetch_token()`| requests an SSO token using Authorization Code grant with [PKCE](https://oauth.net/2/pkce/) extension |
48
52
|`refresh_token()`| requests an SSO token using [Refresh Token](https://oauth.net/2/grant-types/refresh-token/) grant |
53
+
|`close()`| remove all requests adapter instances |
49
54
|`logout()`| removes token from cache, returns logout URL and optionally signs out using system's default web browser |
50
55
|`vehicle_list()`| returns a list of Vehicle objects |
51
56
|`battery_list()`| returns a list of Battery objects |
@@ -189,6 +194,29 @@ print(vehicles[0])
189
194
tesla.close()
190
195
```
191
196
197
+
#### Alternative staged
198
+
199
+
Support for staged authorization has been added to TeslaPy 2.5.0. The keyword arguments `state` and `code_verifier` are accepted by the `Tesla` class constructor, the `authorization_url()` method and the `fetch_token()` method.
tesla = teslapy.Tesla('[email protected]', state=state, code_verifier=code_verifier)
213
+
ifnot tesla.authorized:
214
+
tesla.fetch_token(authorization_response=input('Enter URL after authentication: '))
215
+
vehicles = tesla.vehicle_list()
216
+
print(vehicles[0])
217
+
tesla.close()
218
+
```
219
+
192
220
#### 3rd party authentication apps
193
221
194
222
TeslaPy 2.4.0+ supports usage of a refresh token obtained by 3rd party [authentication apps](https://teslascope.com/help/generating-tokens). The refresh token is used to obtain an access token and both are cached for persistence, so you only need to supply the refresh token only once.
0 commit comments