mlowijs / tesla_api

Lightweight Python API client for the Tesla API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

New oauth2 token for MFA (existing auth not working)

one4many opened this issue · comments

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

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.

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.

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.

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.

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.'}

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.

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

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

Hi, any news on this issue?

Hi, any news on this issue?

#39 perfectly worked for me as @Dreamsorcerer said

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

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

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

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.