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

New oauth2 token for MFA (existing auth not working) #31

Open
one4many opened this issue Dec 3, 2020 · 14 comments
Open

New oauth2 token for MFA (existing auth not working) #31

one4many opened this issue Dec 3, 2020 · 14 comments

Comments

@one4many
Copy link

one4many commented Dec 3, 2020

A few weeks ago Tesla introduced MFA (Multi Factor Authentication) which essentially breaks this lib when the Tesla customer has MFA activated. Please fix.

@Dreamsorcerer
Copy link
Collaborator

Presumably we'll just need to update the token authentication at:
https://github.com/mlowijs/tesla_api/blob/master/tesla_api/__init__.py#L69

Appears to be information about how to implement this at: timdorr/tesla-api#215

Feel free to play around and try to get it working. Otherwise, I'll try to have a look in a few weeks.

@one4many
Copy link
Author

one4many commented Dec 3, 2020

The challenge is to obtain the token in the first place (at least in a server based environment). Username and password alone are not going to cut it anymore without the 2nd factor. Additionally the (new) oauth2 based tokens are only valid for 300 seconds. With the trick described in timdorr/tesla-api#215 you can obtain the old style tokens which a valid for 45 days. A more desirable duration for server based applications.

@Dreamsorcerer
Copy link
Collaborator

Right, sounds like the MFA token is an initial auth token, which can then be used to request a long-lived token from the token endpoint.

So, first step is to add a method to handle the MFA, which sounds like it requires returning a URL to the user to authenticate.
Second step, is to extend that to request the normal API token using that short-lived auth token.

@tbee
Copy link

tbee commented Jan 1, 2021

Right. Thanks all for the info! I assume no one has a Java implementation laying around? :-D To the keyboard then. TeslaTasks is starting to stumble as well.

This was referenced Jan 29, 2021
@Dreamsorcerer Dreamsorcerer changed the title New oauth2 token for MFA New oauth2 token for MFA (existing auth not working) Jan 30, 2021
@ralequi
Copy link

ralequi commented Feb 1, 2021

It seems the auth have stopped working at all.

The contents of self._token at TeslaApiClient.authenticate(self)

{'response': 'endpoint_deprecated:_please_update_your_app.'}

@tbee
Copy link

tbee commented Feb 1, 2021

Tesla has stopped the old API. Accounts with MFA active still work through the v3 API, I have not been able to get non MFA account working yet.

@Dreamsorcerer
Copy link
Collaborator

@ralequi Please try out #39. Still a work in progress though.

@one4many
Copy link
Author

one4many commented Feb 1, 2021

@ralequi for token renewal you might need #38 as well (which will end up in #39 eventually)

@gotgot04
Copy link

Hi, any news on this issue?

@ralequi
Copy link

ralequi commented Apr 10, 2021

Hi, any news on this issue?

#39 perfectly worked for me as @Dreamsorcerer said

@tbee
Copy link

tbee commented Apr 11, 2021

I've only got the MFA version working for teslatasks. But I figure it's not such a bad thing.

@scienceintheshed
Copy link

I've had this working for a few weeks now with all my old endpoints, but there seems to be a new issue as of this morning. Have raised #43

@hawkeye217
Copy link

Having the same issue as @scienceintheshed as well. All worked well for a few weeks until recently.

@tbee
Copy link

tbee commented May 9, 2021

Yup. My Java version of TeslaAPI is getting a 403 now as well. Seems Tesla is slowly moving things over to something new. It also seems that any already obtained long lived tokens are still working.

Changing the authorize and token URL to "v1" instead of "v3" fixes things.

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

No branches or pull requests

7 participants