-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update user/pass authentication. #39
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.