JakobLichterfeld / Tesla_API_in_Tasker

access the Tesla API in Tasker (Android App)
MIT License
13 stars 0 forks source link

Use OAuth2.0 v3 Authentication #6

Open JakobLichterfeld opened 3 years ago

JakobLichterfeld commented 3 years ago

see https://tesla-api.timdorr.com/api-basics/authentication

MikeBishop commented 3 years ago

FWIW, I think if there's a way to have a web view in Tasker, you might be able to do the same thing the Tesla app now does - launch the starting URL and watch for the web view to hit the fake result URL. I don't know Tasker well enough to know if that's possible.

tony06077 commented 3 years ago

Would you create a 'auth.tesla.cn' profile for me?

JakobLichterfeld commented 3 years ago

Hopefully find the time to do so. Pull requests are welcome too 😉

lLarryLaffer commented 3 years ago

Is there an easy workaround to bypass the {"response":null,"error":"Endpoint deprecated"...} message from the "Tesla API Token Get/Refresh/Valid"-Task?

MikeBishop commented 3 years ago

@lLarryLaffer, there's not. This profile uses the old auth endpoint, so until it's updated, there's not much to do.

JakobLichterfeld commented 3 years ago

As an update, as I found some time yesterday: I was able to generate the code_verifier and the SHA256 code_challenge with the help of JavaScript and Crypto-JS Library. The rest should be straight forward. So there is light at the end of the tunnel.

JakobLichterfeld commented 3 years ago

Is there an easy workaround to bypass the {"response":null,"error":"Endpoint deprecated"...} message from the "Tesla API Token Get/Refresh/Valid"-Task?

@lLarryLaffer: As a workaround you can directly set the %Tesla_token under VARS to a valid token (generated by python script on pc or whatever) and set %Tesla_token_expires_in to 9999999999999999 until I updated the code

JakobLichterfeld commented 3 years ago

As an update, as I found some time yesterday evening: Finally, I was able to do the same steps as the official Tesla App does, and find the hidden input fields. Now struggeling with easy way of export _csrf, _phase, _process, transaction_id, and cancel values. Looking into the new HTML/XML Reading feature. --> Only a matter of time

rubin110 commented 3 years ago

Curious if this is in the current play store build now? I've got my access and refresh tokens. Sticking both in the OAuth Token and OAuth Refresh Token fields throws up an error. I can put the access token in the Access Token field but I'm guessing it's ignoring the Refresh Token field at that point?

JakobLichterfeld commented 3 years ago

Hi Rubin,

Curious if this is in the current play store build now?

Tesla API in Tasker is not listed in the Google play store, only GitHub and Taskernet

I've got my access and refresh tokens. Sticking both in the OAuth Token and OAuth Refresh Token fields throws up an error. I can put the access token in the Access Token field but I'm guessing it's ignoring the Refresh Token field at that point?

As wrote above: you need to set %Tesla_token_expires_in to 9999999999999999 for current workaround, and yes refresh token is also broken in current version, due to the Oath V3 update by Tesla.

Hope this helps.