A Python module to use the Tesla Motors Owner API

A Python implementation based on unofficial documentation of the client side interface to the Tesla Motors Owner API, which provides functionality to monitor and control Tesla products remotely.
Overview
This module depends on Python requests, requests_oauthlib and websocket-client. The Tesla
class extends requests.Session
and therefore inherits methods like get()
and post()
that can be used to perform API calls. All calls to the Owner API are intercepted by the request()
method to add the JSON Web Token (JWT) bearer, which is acquired after authentication. Module characteristics:
- It implements Tesla’s new OAuth 2 Single Sign-On service.
- Acquired tokens are cached to disk (cache.json) for persistence.
- The cache stores tokens of each authorized identity (email).
- Authentication is only needed when a new token is requested (usually once).
- The token is automatically refreshed