Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Update user/pass authentication. #39

wants to merge 1 commit into from

Conversation

Dreamsorcerer
Copy link
Collaborator

@Dreamsorcerer Dreamsorcerer commented Jan 31, 2021

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.

"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:
Copy link

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.

Copy link
Collaborator Author

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)))
Copy link

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. ;)

Copy link
Collaborator Author

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.

Copy link

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.

@dsully
Copy link

dsully commented Jun 7, 2021

Looks like this is missing a new file: exceptions.py

@Dreamsorcerer
Copy link
Collaborator Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants