mlowijs / tesla_api

Lightweight Python API client for the Tesla API.
MIT License
80 stars 31 forks source link

0 - Api token #23

Closed Dreamsorcerer closed 4 years ago

Dreamsorcerer commented 4 years ago

-- I need to build these PRs off of each other, in order to continue testing them in my application. So, I'm numbering these new PRs, so you can look through them in order. The diffs should be easy to review once all preceeding PRs have been merged. --

This PR changes the token behaviour, so rather than needing to use the API, and then extract the token, it uses a callback passed into the constructor which is passed the token whenever a new token is created.

The biggest issue with the previous approach, is that there was no way to know when the token gets refreshed and needs saving again.