Closed michis0806 closed 3 years ago
Hey there @zabuldon, @alandtse, mind taking a look at this issue as it has been labeled with an integration (tesla
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
tesla documentation tesla source (message by IssueLinks)
Same here. I cannot login with any account, no matter whether it has 2fa enabled or not.
Just updated to core-2021.8.2 and now seeing the same.
Same here as well, just tried it after enabling 2FA and no go.
The "me too posts" clutters the thread. Please +1 the original post if you are having this issue.
That said, I will not be working on this for reasons described here.
Alternatively, someone posted a workaround for advanced users who want to manually log in and copy their tokens over. Modifying .storage directly is not recommended so proceed with caution.
It seems every other time I upgrade HA, the Tesla integration breaks :-/
I'm on core-2021.8.3 and still hitting it. Debug log, sanitized anything that looked like a UUID or a token.
2021-08-07 10:51:00 DEBUG (MainThread) [teslajsonpy.connection] Attempt #1
2021-08-07 10:51:00 DEBUG (MainThread) [httpx._client] HTTP Request: POST https://auth.tesla.com/oauth2/v3/authorize?client_id=ownerapi&code_challenge=SANITIZE&code_challenge_method=S256&redirect_uri=https://auth.tesla.com/void/callback&response_type=code&scope=openid+email+offline_access&state=SANITIZE "HTTP/1.1 200 OK"
2021-08-07 10:51:00 DEBUG (MainThread) [teslajsonpy.connection] POST:
https://auth.tesla.com/oauth2/v3/authorize?client_id=ownerapi&code_challenge=SANITIZE&code_challenge_method=S256&redirect_uri=https://auth.tesla.com/void/callback&response_type=code&scope=openid+email+offline_access&state=SANITIZE with
Headers({'host': 'auth.tesla.com', 'accept': '*/*', 'accept-encoding': 'gzip, deflate', 'connection': 'keep-alive', 'user-agent': 'HomeAssistant/2021.8.3 httpx/0.18.2 Python/3.9', 'cookie': '_abck=SANITIZE; ak_bmsc=SANITIZE; bm_sv=SANITIZE=; bm_sz=SANITIZE; tesla-auth.sid=sSANITIZE', 'content-length': '178', 'content-type': 'application/x-www-form-urlencoded'})
returned 200:OK with response Headers([('content-type', 'text/html; charset=utf-8'), ('x-dns-prefetch-control', 'off'), ('x-frame-options', 'DENY'), ('strict-transport-security', 'max-age=15552000; includeSubDomains'), ('x-download-options', 'noopen'), ('x-content-type-options', 'nosniff'), ('x-xss-protection', '1; mode=block'), ('x-request-id', 'SANITIZE'), ('x-correlation-id', 'SANITIZE'), ('cache-control', 'no-store'), ('content-security-policy', "connect-src 'self'; default-src 'none'; font-src 'self' data: fonts.gstatic.com; frame-src 'self' www.google.com www.recaptcha.net; img-src 'self' data:; script-src www.recaptcha.net 'self' 'nonce-SANITIZE'; style-src 'unsafe-inline' 'self'"), ('x-content-security-policy', "connect-src 'self'; default-src 'none'; font-src 'self' data: fonts.gstatic.com; frame-src 'self' www.google.com www.recaptcha.net; img-src 'self' data:; script-src www.recaptcha.net 'self' 'nonce-SANITIZE'; style-src 'unsafe-inline' 'self'"), ('x-webkit-csp', "connect-src 'self'; default-src 'none'; font-src 'self' data: fonts.gstatic.com; frame-src 'self' www.google.com www.recaptcha.net; img-src 'self' data:; script-src www.recaptcha.net 'self' 'nonce-SANITIZE'; style-src 'unsafe-inline' 'self'"), ('etag', 'SANITIZE"'), ('x-response-time', '27.014ms'), ('content-encoding', 'gzip'), ('x-edgeconnect-midmile-rtt', '52'), ('x-edgeconnect-origin-mex-latency', '82'), ('originip', 'SANITIZE'), ('x-akamai-transformed', '9 6118 0 pmb=mTOE,1'), ('date', 'Sat, 07 Aug 2021 17:51:00 GMT'), ('content-length', '5949'), ('connection', 'keep-alive'), ('vary', 'Accept-Encoding'), ('set-cookie', 'tesla-auth.sid=sSANITIZE; Path=/; Expires=Tue, 10 Aug 2021 17:51:00 GMT; HttpOnly; Secure; SameSite=Lax'), ('origin_hostname', 'auth.tesla.com'), ('permissions-policy', 'interest-cohort=()'), ('set-cookie', 'bm_sv=SANITIZE=; Domain=.tesla.com; Path=/; Max-Age=7197; HttpOnly')])
The response looks like a captcha.
Still an issue with 2021.8.4
It seems every other time I upgrade HA, the Tesla integration breaks :-/
And it is strange that other API-users seem not to have so many problems - tibber for instance. https://support.tibber.com/en/articles/4408566-smart-charging-explained
I use an app called A Better Routeplanner to plan out multi waypoint trips with my car. It offers to poll data from the car through the Tesla API in order to adjust estimations and when to charge the car where.
Anyhow, I noticed the other day it wasn't providing live data anymore, and just now had time to investigate. This is the screen I would typically type in my Tesla account credentials in order for their service to gain a token from Tesla, I don't remember there being a captcha here before.
So I'm guessing their API is requiring captcha completion for some (not all) of the logins, and the HA integration isn't setup to deal with that usecase?
So I'm guessing their API is requiring captcha completion for some (not all) of the logins, and the HA integration isn't setup to deal with that usecase?
Correct. That is the cause.
It would be nice if we could be given the option to provide an API token instead of user/pass[/mfa].
Not sure if that would fix the problem.
Do a search for tesla
in /hass/homeassistant/.storage/core.config_entries
. Though I'm not sure if this entry is related to the older version of the extension prior to the auth change. I'll give it a try later this evening and see if sticking my keys in here work.
Workaround for TeslaFi users (or the ones who can obtain auth keys from other similar service):
The result will look like this:
{
"entry_id": "f0a8a...51fdb",
"version": 1,
"domain": "tesla",
"title": "you@gmail.com",
"data": {
"token": " < New Refresh Token from TeslaFi>",
"access_token": "<New Token>",
"username": "you@gmail.com",
"password": "well,yeah",
"expiration": 1828416519
},
It would be nice if we could be given the option to provide an API token instead of user/pass[/mfa].
Not sure if that would fix the problem.
Please test this branch to log in with your tesla refresh and access tokens. (Username = refresh token, Password = access token). Use this app to obtain both of those tokens. If that works I will create a new config flow option to use your refresh token to login. (The access token can be generated by itself once this fix gets merged to teslajsonpy)
Keep in mind that this is not a fix for production use, this is just for texting and WILL break.
It would be nice if we could be given the option to provide an API token instead of user/pass[/mfa]. Not sure if that would fix the problem.
Please test this branch to log in with your tesla refresh and access tokens. (Username = refresh token, Password = access token). Use this app to obtain both of those tokens. If that works I will create a new config flow option to use your refresh token to login. (The access token can be generated by itself once this fix gets merged to teslajsonpy)
I was able to authenticate and add the car to HASS again. But I get an error when it tries to fetch actual data it seems.
2021-08-09 19:37:12 ERROR (MainThread) [homeassistant.components.tesla] Error fetching tesla data: Error communicating with API:
All sensors are unavailable.
It would be nice if we could be given the option to provide an API token instead of user/pass[/mfa]. Not sure if that would fix the problem.
Please test this branch to log in with your tesla refresh and access tokens. (Username = refresh token, Password = access token). Use this app to obtain both of those tokens. If that works I will create a new config flow option to use your refresh token to login. (The access token can be generated by itself once this fix gets merged to teslajsonpy)
I was able to authenticate and add the car to HASS again. But I get an error when it tries to fetch actual data it seems.
2021-08-09 19:37:12 ERROR (MainThread) [homeassistant.components.tesla] Error fetching tesla data: Error communicating with API:
All sensors are unavailable.
Expected as much, this was just for testing. Ill be pushing a change on there that should allow it to work past the initial setup phase today or tomorrow.
Workaround for TeslaFi users (or the ones who can obtain auth keys from other similar service):
- Go to TeslaFi "Settings - Tesla Account - Generate new token"
- Select " Display Token:" on that page
- Enter Tesla credentials and captcha
- On the result page, save "New Refresh Token" (the long one) and "New Token" (starts with qts- usually)
- stop Home Assistant
- Open < Hass Config Dir >/.storage/core.config_entries
- Find entry with domain": "tesla"
- Replace data/token with "New Refresh Token" and data/access_token with "New Token" from above.
- Add "expiration": 1828416519 at the same level (or use another future UnixTime entry)
The result will look like this:
{ "entry_id": "f0a8a...51fdb", "version": 1, "domain": "tesla", "title": "you@gmail.com", "data": { "token": " < New Refresh Token from TeslaFi>", "access_token": "<New Token>", "username": "you@gmail.com", "password": "well,yeah", "expiration": 1828416519 },
- Start Home Assistant. It will be able to get data until the token expires (month or so)
Thanks, worked fine!
Just so I can wrap my head around how the SSO refresh token. If the token is cycled by a different client hitting the endpoint with the same token as what's entered in HA, will HA be able to roll the token forward itself too?
Workaround for TeslaFi users (or the ones who can obtain auth keys from other similar service):
* Go to TeslaFi "Settings - Tesla Account - Generate new token" * Select " Display Token:" on that page * Enter Tesla credentials and captcha * On the result page, save "New Refresh Token" (the long one) and "New Token" (starts with qts- usually) * stop Home Assistant * Open < Hass Config Dir >/.storage/core.config_entries * Find entry with domain": "tesla" * Replace data/token with "New Refresh Token" and data/access_token with "New Token" from above. * Add "expiration": 1828416519 at the same level (or use another future UnixTime entry)
The result will look like this:
{ "entry_id": "f0a8a...51fdb", "version": 1, "domain": "tesla", "title": "you@gmail.com", "data": { "token": " < New Refresh Token from TeslaFi>", "access_token": "<New Token>", "username": "you@gmail.com", "password": "well,yeah", "expiration": 1828416519 },
* Start Home Assistant. It will be able to get data until the token expires (month or so)
I guess this doesn't work if I've removed the integration already? I can't re-add it because it gives me the error upon attempting to do so.
Workaround for TeslaFi users (or the ones who can obtain auth keys from other similar service):
* Go to TeslaFi "Settings - Tesla Account - Generate new token" * Select " Display Token:" on that page * Enter Tesla credentials and captcha * On the result page, save "New Refresh Token" (the long one) and "New Token" (starts with qts- usually) * stop Home Assistant * Open < Hass Config Dir >/.storage/core.config_entries * Find entry with domain": "tesla" * Replace data/token with "New Refresh Token" and data/access_token with "New Token" from above. * Add "expiration": 1828416519 at the same level (or use another future UnixTime entry)
The result will look like this:
{ "entry_id": "f0a8a...51fdb", "version": 1, "domain": "tesla", "title": "you@gmail.com", "data": { "token": " < New Refresh Token from TeslaFi>", "access_token": "<New Token>", "username": "you@gmail.com", "password": "well,yeah", "expiration": 1828416519 },
* Start Home Assistant. It will be able to get data until the token expires (month or so)
I guess this doesn't work if I've removed the integration already? I can't re-add it because it gives me the error upon attempting to do so.
I went into my backups to retrieve an older version of core.config_entries
and pasted the Tesla block in with the updated tokens from TeslaFi. Still didn't work for me. Getting the invalid config error still in the Tesla integration. But the integration DID show back up since I had removed it before.
@bdoooh Did you push back the expiration time?
@bdoooh Did you push back the expiration time?
Yeah I input the expiration date in September specified in TeslaFi into the unix time converter and copied that value. I can double check & try again I guess.
Edit: Yeah I just checked the config_entries and this is what I have..
{
"entry_id": "d48a....244",
"version": 1,
"domain": "tesla",
"title": "xxxxxxxx",
"data": {
"username": "xxxxxxxx",
"password": "xxxxxxxx",
"access_token": "qts-xxxxxxxx",
"token": "xxxxxxxx",
"expiration": 1631500149
},
"options": {
"scan_interval": 660
},
"pref_disable_new_entities": false,
"pref_disable_polling": false,
"source": "import",
"unique_id": null,
"disabled_by": null
},
I need this to be solved, all my automations are broken 😢
@bdoooh I had botched up pasting my API keys on my first attempt. Try looking at your logs for any mention of tesla
. You may need to change your default logging level to get more details.
@mat1990dj @denisjoshua : The workaround listed in this previous comment worked for me. You can grab your API keys from this app on Android, if you search around there's a similar app for iOS. If you know how to edit your configuration.yaml
file directly on your HASS machine, you're capable of making this work around go in order to fix your crucial automations.
If you need a proper solution, feel free to fix the code and drop a pull request as per the guidelines of this open source project, or wait for a volunteer dev to get to this issue. Otherwise that workaround does indeed work.
I don't know how to edit my configuration.yaml file directly on my HASS machine in my case
De: Rubin Starset @.> Enviado: jueves, 12 de agosto de 2021 17:14 Para: home-assistant/core @.> Cc: mat1990dj @.>; Mention @.> Asunto: Re: [home-assistant/core] Tesla authentication fails (#54177)
@bdooohhttps://github.com/bdoooh I had botched up pasting my API keys on my first attempt. Try looking at your logs for any mention of tesla. You may need to change your default logging levelhttps://www.home-assistant.io/integrations/logger/#log-levels to get more details.
@mat1990djhttps://github.com/mat1990dj @denisjoshuahttps://github.com/denisjoshua : The workaround listed in this previous commenthttps://github.com/home-assistant/core/issues/54177#issuecomment-895396446 worked for me. You can grab your API keys from this app on Androidhttps://play.google.com/store/apps/details?id=net.leveugle.teslatokens, if you search around there's a similar app for iOS. If you know how to edit your configuration.yaml file directly on your HASS machine, you're capable of making this work around go in order to fix your crucial automations.
If you need a proper solution, feel free to fix the code and drop a pull request as per the guidelines of this open source projecthttps://github.com/home-assistant/core/blob/master/CONTRIBUTING.md, or wait for a volunteer dev to get to this issue. Otherwise that workaround does indeed work.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/54177#issuecomment-897724607, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABH2NW5G5C27DZ7WOWTDO3DT4PQOXANCNFSM5BWSWJZQ. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email.
The workaround listed in this previous comment worked for me
Thanks a lot Rubin, but I prefer to wait the official add-on "repair" ...cause then I'll forget and I will not put all back :-)
Thanks a lot Denis
@denisjoshua : There shouldn't be any sort of need to put it all back to its prior configuration. I'm assuming the fix will simply be "do thing that Tesla expects for proper authorization during the 'log in' step." All that authorizing does is pull down those API keys for your account (which should be identical) and save them to < Hass Config Dir >/.storage/core.config_entries
. For my setup, since I already provided the keys manually, the next update to the Tesla integration will first try the keys since they're populated, and if they work just functional normally. Resetting the core.config_entries
file back to how it was originally will simply force the Tesla integration to do that login step again and just insert in the same API keys I already fed it, those two values will look identical to what I entered in previously.
If that isn't the case on the next update, I'll eat my shoe.
I got it resolved. I had to set the token
value to the Refresh Token
value from TeslaFi and not the Refresh Token New
, the super long one. Not sure how or why the rest of you are able to get to work with the long one.
I also removed the Tesla config out of configurations.yaml
and for some reason that helped fix it as well.
and save them to
< Hass Config Dir >/.storage/core.config_entries
I have no more tesla in my /.storage/core.config_entries cause I have uninstall the integration and now I can't install it anymore because of error. Is there a way to install it anyway please ?
Thanks a lot Denis
and save them to
< Hass Config Dir >/.storage/core.config_entries
I have no more tesla in my /.storage/core.config_entries cause I have uninstall the integration and now I can't install it anymore because of error. Is there a way to install it anyway please ?
Thanks a lot Denis
You'll need a way to generate a new entry_id
but you can copy my block from above. I just ended up restoring from a backup I had from over a month ago and copying that entry.
Oh :-( I have see only now that my Home Assistant Goole Drive Backup add-on save only the last 3 days the backups. Now I have set it to backup weekly and mounthly...
But I have no backup of Tesla add-on in order to put it back again :-( Is there some other solution please ?
Thanks a lot Denis
I guess it wasn't clearly stated when I first responded to this thread. I have a custom component for Tesla in HACS that doesn't have the login issue. So if you can't wait for an official fix and can't do the work around, you can use that instead. It's a drop in replacement since it uses the same underlying ids. It's probably lower quality since it's not reviewed by the HA team but I also put features (e.g. energy sensor) in there before here.
Do not post bug reports for it here though.
Thanks a lot... I'll try today. Denis
I have a custom component for Tesla
Hei Alan... it's work :-) Thanks a lot again
In a recent change to the Tesla integration( #53245 ) the MFA process was changed by @bdraco Could this have something to do with the current issues?
In a recent change to the Tesla integration( #53245 ) the MFA process was changed by @bdraco Could this have something to do with the current issues?
No. Tesla added a captcha.
Can we pass the captcha through Home Assistant to the user when getting the API keys?
Can we pass the captcha through Home Assistant to the user when getting the API keys?
That or just let us put in the token manually would work too.
You're both right, ideally we should provide both options.
The User/Pass/Captcha/2FA workflow should remain, so that the integration stays user-friendly and easy to set up for non-technical folks.
And then a small button at the bottom that says "Provide auth tokens instead" that switches to text areas for your access and refresh tokens (which are what these iOS and Android apps mentioned above provide).
That way, even if the authentication breaks again, savvy users can still use auth tokens to make the integration function as a workaround / backup plan.
Alternatively, could HASS link to the Tesla website for authentication when the built-in methods fail?
On Thu, Aug 19, 2021 at 6:04 PM Jake Burgy @.***> wrote:
You're both right, ideally we should provide both options.
The User/Pass/Captcha/2FA workflow should remain, so that the integration stays user-friendly and easy to set up for non-technical folks.
And then a small button at the bottom that says "Provide auth tokens instead" that switches to text areas for your access and refresh tokens (which are what these iOS and Android apps mentioned above provide).
That way, even if the authentication breaks again, savvy users can still use auth tokens to make the integration function as a workaround / backup plan.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/54177#issuecomment-902353577, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAY7BC2672VVRAXW4SQARTT5WS2RANCNFSM5BWSWJZQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .
secabeen wrote: Can we pass the captcha through Home Assistant to the user when getting the API keys?
Yes, but someone has to implement it. It's incredibly fragile and after doing it for one integration, I don't intend to do it here in core. Unfortunately, zabuldon hasn't contributed here for years now so that leaves someone new stepping in. We really do need another codeowner. I might take myself off codeowners, but I haven't since I'm willing to help review PRs which is better than nothing.
ideal2545 wrote: That or just let us put in the token manually would work too.
This probably would work best and I'd support that. I don't know of it'd be allowed though since it's not user friendly as pointed out below. Doesn't hurt to try but I'd suggest asking in discord.
qjake wrote: You're both right, ideally we should provide both options.
The User/Pass/Captcha/2FA workflow should remain, so that the integration stays user-friendly and easy to set up for non-technical folks.
And then a small button at the bottom that says "Provide auth tokens instead" that switches to text areas for your access and refresh tokens (which are what these iOS and Android apps mentioned above provide).
That way, even if the authentication breaks again, savvy users can still use auth tokens to make the integration function as a workaround / backup plan.
While ideal, this is really complex since you're suggesting two separate login paths to maintain. If someone wants to maintain this then all the power to them.
I'm debating whether my custom component should just be rewritten as an auth integration since it'd lower my maintenance requirements but would stop me from adding new features there. Also, I'm not sure it'd be sanctioned by core for me to modify core's settings directly. There's already concern that any integration has full access to every other integration's data. If it became a standard practice, that'd be a security nightmare and may introduce a lock down on that (assuming they don't have to rewrite core).
j9brown wrote: Alternatively, could HASS link to the Tesla website for authentication when the built-in methods fail?
No. Tesla does not allow third party auth. If they did, we wouldn't have this problem to begin with. Baloob actually tried tweeting elonmusk about this but I don't think it went anywhere.
You're both right, ideally we should provide both options.
The User/Pass/Captcha/2FA workflow should remain, so that the integration stays user-friendly and easy to set up for non-technical folks.
And then a small button at the bottom that says "Provide auth tokens instead" that switches to text areas for your access and refresh tokens (which are what these iOS and Android apps mentioned above provide).
That way, even if the authentication breaks again, savvy users can still use auth tokens to make the integration function as a workaround / backup plan.
Even simpler IMHO (I really do not know very much about the internals of HA/integrations):
if the token is provided in configuration.yaml or secrets.yaml: use it, if not: run the standard way (and I would not care too much if that breaks).
The situation just now is a PITA.
Can maybe @frenck have some from HA core Team take a look at it and help? It seems there is no one capable to take over the role of code owner right now and code is broken for this official integration.
For those interested in using Postman to obtain the access token and refresh token, you can follow this https://github.com/jdemeyer1/TeslaAPIThruPostman.
Seeing the same problem. Can someone post a quick summary of the workaround? I don't have TeslaFI
Okay, even though many of you liked the idea @frenck replied with an indirect "f*ck off" so I no solution from the HA team then ^^
@Nicao I think that's because there is no "HA Core Team".... there are moderators who try to aim the efforts in the same direction, but this is oss, everyone is the team.
It wasn't an indirect "f*ck off" it was indirect "Not cool": You pulled me into a conversation. In general, it is unpolite to randomly mention someone and ask for support. This is also documented in our community guidelines.
I don't own a Tesla, nor have I any idea what is going on. Please don't tag/mention people @ random.
Thanks 👍
Hello guys, As I can see there is a huge discussion around Tesla component. Let me explain why I'm not contributing this anymore. I don't have Tesla anymore, so it is not easy to support this whiothout having a cat, so if someone ready to help with troubleshooting I can spend some time to work on the integration again, but I'm not sure if that issue not occurs again in the future. Ideal solution in this case to find out a new maintainer.
The problem
My Tesla-integration stopped working yesterday without any changes on the Tesla-accout or the home assistant integration.
What is version of Home Assistant Core has the issue?
core-2021.8.2
What was the last working version of Home Assistant Core?
core-2021.8.2
What type of installation are you running?
Home Assistant Container
Integration causing the issue
Tesla
Link to integration documentation on our website
https://www.home-assistant.io/integrations/tesla/
Example YAML snippet
No response
Anything in the logs that might be useful for us?
Additional information
credentials are working on tesla.com. I tried to uninstall integration, restart home assistant, re-install integration. Error occurs again.