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

Tesla API doesn't work any more #624

Closed
naltatis opened this issue Jan 30, 2021 · 15 comments · Fixed by #626
Closed

Tesla API doesn't work any more #624

naltatis opened this issue Jan 30, 2021 · 15 comments · Fixed by #626
Labels
bug Something isn't working

Comments

@naltatis
Copy link
Member

Describe the bug
Tesla has deprecated the authentication endpoint that's indirectly used via evcc.

To Reproduce
Configure a vehicle with Tesla credentials and run evcc vehicle

Expected behavior
I recieve a 400 Bad Request. No vehicle information is shown.

EVCC details:
Show output of evcc -v:

./evcc --log trace vehicle
[main  ] INFO 2021/01/30 10:50:17 evcc 0.0.1-alpha (HEAD)
[main  ] INFO 2021/01/30 10:50:17 using config file /Users/michael/lab/evcc/evcc.yaml
[main  ] FATAL 2021/01/30 10:50:18 cannot create vehicle 'tesla': cannot create type 'tesla': 400 Bad Request

Executing the auth request agains the Tesla api returns 400 Bad Request and this response:

{
    "response": "endpoint_deprecated:_please_update_your_app."
}

The deprecation has been known for some time but now it seems the be gone.
See: https://tesla-api.timdorr.com/api-basics/authentication

⚠ This information is out of date ⚠
Tesla has deprecated the /oauth/token endpoint in favor of using auth.tesla.com. I'm working on updating the documentation as soon as possible. Feel free to discuss this in issue 215.

More details here: timdorr/tesla-api#215 (comment)

@andig andig added the bug Something isn't working label Jan 30, 2021
@martinez81
Copy link

Der Bug zeigt sich bei mir auch.

@andig
Copy link
Member

andig commented Jan 30, 2021

Habt ihr MFA irgendwie manuell aktiviert? Anderenfalls scheint die Umstellung von Tesla zu kommen. Zum Testen bräuchte ich Zugangsdaten.

@martinez81
Copy link

martinez81 commented Jan 30, 2021

Habt ihr MFA irgendwie manuell aktiviert?

Was ist MFA?

@andig
Copy link
Member

andig commented Jan 30, 2021

2FA oder MFA = Multi Factor Authentication

Screenshot 2021-01-30 at 16 29 20

Ist die bei Dir an @martinez81?

@andig
Copy link
Member

andig commented Jan 30, 2021

Halbe Lösung. Mit gültigem Token gehts erstmal weiter. Das muss allerdings anderweitig erzeugt werden. Die Erzeugung könnten wir erstmal mittels kleinem Workaround ebenfalls mit einbauen, z.B.:

evcc tesla-token

@andig
Copy link
Member

andig commented Jan 30, 2021

Ist drin. Damit kann das Token erzeugt werden (jedenfalls für 2FA) und dann manuell in die Config übernommen.

@martinez81
Copy link

martinez81 commented Jan 30, 2021

2FA oder MFA = Multi Factor Authentication

Screenshot 2021-01-30 at 16 29 20

Ist die bei Dir an @martinez81?

Nein, ist aus.

@andig
Copy link
Member

andig commented Jan 31, 2021

Nein, ist aus.

@martinez81 das ist super. Einen Test mit MFA habe ich jetzt, fehlt noch einer ohne MFA. Falls Du Deine Logindaten teilen würdest würde mir das sehr helfen (cpuidle@gmx.de). Mangels Auto kann ich sonst nicht testen.

@martinez81
Copy link

Mail ist raus..

@naltatis
Copy link
Member Author

evcc tesla-token funktioniert.
Ich bekomme dann ein AccessToken, ein RefreshToken und die Angabe ExpiresIn:300. Wenn ich das AccessToken in meiner Config als token hinterlege klappt die API Kommunikation. Allerdings nur für eine kurze Zeit (ich vermute 5min = 300s). Danach bekomme ich 401 Unauthorized.
Muss das Token regelmäßig mit dem RefreshToken refreshed werden um auf die 45 Tage Laufzeit zu kommen?

@andig
Copy link
Member

andig commented Feb 1, 2021

evcc tesla-token funktioniert.

Gerade aktualisiert: jetzt werden auch Tokens generiert falls keine MFA aktiv ist. Prinzipiell hätten wir damit eine Lösung die wir einbauen könnten. Wer ohne MFA arbeitet bekommt damit ein Token.

Was jetzt noch fehlt ist der Token Refresh damit EVCC auch wieder in Ruhe ohne Neustarts laufen kann.

@naltatis
Copy link
Member Author

naltatis commented Feb 1, 2021

Ja, die Lösung funktioniert seit gestern problemlos bei mir. Jetzt wo die Debug Meldung raus ist gibts auch kein Verwirrungspotential mehr.

@andig
Copy link
Member

andig commented Feb 3, 2021

@ALL: gerne nochmal testen. Die Lösung ist jetzt rund und sollte auch Token Refresh unterstützen. Alternativ: ich schiebs durch...

@naltatis
Copy link
Member Author

naltatis commented Feb 3, 2021

Das generierte Token funktioniert mit der API. Ob's in ein paar Wochen auch korrekt refresht wird kann ich natürlich erst dann sagen :) Aber ich würde dann einfach ein neues Ticket aufmachen wenns dann hakt.

@andig andig closed this as completed in #626 Feb 3, 2021
@andig
Copy link
Member

andig commented Feb 3, 2021

Dir fehlt noch der Refreshtoken und die Syntax ist anders. Erzeug Dir nochmal einen Neuen, dann siehst Du es.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants