Conversation
| "code_verifier": code_verifier, | ||
| "redirect_uri": "https://auth.tesla.com/void/callback" | ||
| } | ||
| async with self._session.post("https://auth.tesla.com/oauth2/v3/token", json=data) as resp: |
There was a problem hiding this comment.
Using magic URLs in mid code is not a good idea when having other (similar) URLs defined as static vars at the beginning/top.
There was a problem hiding this comment.
Hence cleanup still needed. This is just a first pass before I went to bed.
| # Send token to application via callback. | ||
| if self._new_token_callback: | ||
| asyncio.create_task(self._new_token_callback(json.dumps(response_json))) | ||
| asyncio.create_task(self._new_token_callback(json.dumps(access_token))) |
There was a problem hiding this comment.
Changing the interface here from the full token (in past) to just the (new) access_token might brake existing applications. At least it breaks mine. ;)
There was a problem hiding this comment.
This is the same token as before (just with the refresh token replaced).
I still need to test with the old tokens, but if you can point out how it's broken that might save me some time.
There was a problem hiding this comment.
my bad I just read access_token and assumed it would be just the one. Maybe a name change of the var would be better.
|
Looks like this is missing a new file: |
|
Not sure what you mean? It's in the branch (and already exists in master): https://github.com/mlowijs/tesla_api/blob/fix-auth/tesla_api/exceptions.py |
Still need to clean it up, handle refresh tokens and ensure that old tokens are handled gracefully.
Later, we will want to add an alternative authentication method for web applications, so they can redirect users to the Tesla login page without needing their credentials.