Giter VIP home page Giter VIP logo

Comments (40)

alandtse avatar alandtse commented on May 18, 2024 3

Thanks. I've confirmed the workaround works from @sillyfrog . Here's how you do it with less steps but potentially two browsers. You only need to use the auth.tesla.com redirect to get past the first step. It's possible that if you get prompted by MFA or some other secondary page, the login will break but luckily the component remembers the state it's in.

  1. On the computer accessing HA, modify the hosts file so auth.tesla.com points to your HA server. For example, if it's at 192.168.1.3
192.168.1.3	auth.tesla.com
  1. Use that computer and access HA normally with your browser (BROWSER A). Add the custom integration. See the Recaptcha error.
  2. In a new browser window (BROWSER B), copy the url to the new browser window. Chrome may give security warnings and not allow you to change to http. If that happens, use something besides chrome.
  3. Edit the url so it starts with http://auth.tesla.com:8123 instead of your HA domain. https://hadomain.local/auth/tesla/proxy?config_flow_id=8e739ab41fdd4e76a380f173e5c02435&callback_url=https://hadomain.local/auth/tesla/callback?flow_id%3D8e739ab41fdd4e76a380f173e5c02435
    ->
    http://auth.tesla.com:8123/auth/tesla/proxy?config_flow_id=8e739ab41fdd4e76a380f173e5c02435&callback_url=https://hadomain.local/auth/tesla/callback?flow_id%3D8e739ab41fdd4e76a380f173e5c02435
  4. With Browser B, complete the recaptcha and login.
  5. The component will either complete successfully, or it will timeout with the error below.
    image
  6. If you see this error, switch back to BROWSER A, which should still have the original login url, and refresh the page. It should take you to the next page in the login. Complete like normal.
  7. Revert your hosts file.

from tesla.

awisur avatar awisur commented on May 18, 2024 3

Same here:
Tried the workaround. Captcha appeared OK, but got this:
500 Internal Server Error
Server got itself in trouble

from tesla.

sillyfrog avatar sillyfrog commented on May 18, 2024 2

My current solution is... involved... Using this code and some network trickery:

I'm running HA in a docker container, and I have the SSH server enabled on my computer (a MacOS). From within the docker container I run the command:

ssh <computer username>@<computer IP> -R 8123:localhost:8123

Then, I have updated my /etc/hosts file, and added the line:

127.0.0.1	auth.tesla.com

I then go to my browser on my computer, and navigate to http://auth.tesla.com:8123/ - if everything is working, it'll give you your HA login screen, login, and start the process to add this custom integration. I found on the the popup page that it used my default URL, update just the protocol/domain/port portion (ie: change the start to http://auth.tesla.com:8123 ), then you can login to the Tesla page as you would normally.

When things start working in HA, remove the line you added to your /etc/hosts and log out of the docker container.

There maybe better solutions - but this is the only one I can think of without hacking / running JavaScript in Python (or something similar).

from tesla.

fernandeusto avatar fernandeusto commented on May 18, 2024 1

500 Internal Server Error

Waiting a soluttion. Thanks

from tesla.

zephyrus9MA avatar zephyrus9MA commented on May 18, 2024 1

Seems to work. Thanks for your efforts!

from tesla.

alandtse avatar alandtse commented on May 18, 2024 1

That's really a question for Tesla. So long as they accept your refresh token, then it will keep getting new access tokens. If they invalidate your refresh token, then you have to get a new one.

from tesla.

zephyrus9MA avatar zephyrus9MA commented on May 18, 2024 1

Right

from tesla.

torvenkat avatar torvenkat commented on May 18, 2024

I am getting the same error as well.

from tesla.

tbtgspence avatar tbtgspence commented on May 18, 2024

Same issue for me.

from tesla.

alandtse avatar alandtse commented on May 18, 2024

Please +1 instead of posting a me too post.

The proxy doesn't touch the recaptcha traffic. Please check your browser to see what recaptcha urls you are hitting. Then please compare with the regular auth.tesla.com page.

from tesla.

tbtgspence avatar tbtgspence commented on May 18, 2024

Sorry, I still do not see the +1 option. Is any of this helpful from the console?
`
https://www.recaptcha.net/recaptcha/api2/anchor?ar=1&k=6LdUQhgUAAAAAEe8NWX3Rur9bQRqq-2RUPhthpJs&co=aHR0cHM6Ly80a2h5NHY1cG5wc3Rsa3Z5em1jYWsxd2t6ajBrcnF6Ny51aS5uYWJ1LmNhc2E6NDQz&hl=en&v=wxAi4AKLXL2kBAvXqI4XLSWS&size=normal&badge=bottom-right&cb=sxao31w2n6bi

(anonymous) @ https://www.gstatic.com/recaptcha/releases/wxAi4AKLXL2kBAvXqI4XLSWS/recaptcha__en.js:22
tJ.bottomright.border-radius.render @ https://www.gstatic.com/recaptcha/releases/wxAi4AKLXL2kBAvXqI4XLSWS/recaptcha__en.js:677
(anonymous) @ https://www.gstatic.com/recaptcha/releases/wxAi4AKLXL2kBAvXqI4XLSWS/recaptcha__en.js:58
(anonymous) @ https://www.gstatic.com/recaptcha/releases/wxAi4AKLXL2kBAvXqI4XLSWS/recaptcha__en.js:343
(anonymous) @ https://www.gstatic.com/recaptcha/releases/wxAi4AKLXL2kBAvXqI4XLSWS/recaptcha__en.js:295
HR @ https://www.gstatic.com/recaptcha/releases/wxAi4AKLXL2kBAvXqI4XLSWS/recaptcha__en.js:589
(anonymous) @ https://www.gstatic.com/recaptcha/releases/wxAi4AKLXL2kBAvXqI4XLSWS/recaptcha__en.js:16
loadCaptcha @ https://4khy4v5pnpstlkvyzmcak1wkzj0krqz7.ui.nabu.casa/auth/tesla/proxy?config_flow_id=d23748698d204c84866b7f94a8f3ca52&callback_url=https://4khy4v5pnpstlkvyzmcak1wkzj0krqz7.ui.nabu.casa/auth/tesla/callback?flow_id%3Dd23748698d204c84866b7f94a8f3ca52:24
(anonymous) @ https://www.gstatic.com/recaptcha/releases/wxAi4AKLXL2kBAvXqI4XLSWS/recaptcha__en.js:338
(anonymous) @ https://www.gstatic.com/recaptcha/releases/wxAi4AKLXL2kBAvXqI4XLSWS/recaptcha__en.js:154
O @ https://www.gstatic.com/recaptcha/releases/wxAi4AKLXL2kBAvXqI4XLSWS/recaptcha__en.js:372

<style type="text/css"> /* cyrillic-ext */ @font-face { font-family: 'Roboto'; font-style: normal; font-weight: 400; src: url(//fonts.gstatic.com/s/roboto/v18/KFOmCnqEu92Fr1Mu72xKOzY.woff2) format('woff2'); unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; } /* cyrillic */ @font-face { font-family: 'Roboto'; font-style: normal; font-weight: 400; src: url(//fonts.gstatic.com/s/roboto/v18/KFOmCnqEu92Fr1Mu5mxKOzY.woff2) format('woff2'); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; } /* greek-ext */ @font-face { font-family: 'Roboto'; font-style: normal; font-weight: 400; src: url(//fonts.gstatic.com/s/roboto/v18/KFOmCnqEu92Fr1Mu7mxKOzY.woff2) format('woff2'); unicode-range: U+1F00-1FFF; } /* greek */ @font-face { font-family: 'Roboto'; font-style: normal; font-weight: 400; src: url(//fonts.gstatic.com/s/roboto/v18/KFOmCnqEu92Fr1Mu4WxKOzY.woff2) format('woff2'); unicode-range: U+0370-03FF; } /* vietnamese */ @font-face { font-family: 'Roboto'; font-style: normal; font-weight: 400; src: url(//fonts.gstatic.com/s/roboto/v18/KFOmCnqEu92Fr1Mu7WxKOzY.woff2) format('woff2'); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EF9, U+20AB; } /* latin-ext */ @font-face { font-family: 'Roboto'; font-style: normal; font-weight: 400; src: url(//fonts.gstatic.com/s/roboto/v18/KFOmCnqEu92Fr1Mu7GxKOzY.woff2) format('woff2'); unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; } /* latin */ @font-face { font-family: 'Roboto'; font-style: normal; font-weight: 400; src: url(//fonts.gstatic.com/s/roboto/v18/KFOmCnqEu92Fr1Mu4mxK.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; } /* cyrillic-ext */ @font-face { font-family: 'Roboto'; font-style: normal; font-weight: 500; src: url(//fonts.gstatic.com/s/roboto/v18/KFOlCnqEu92Fr1MmEU9fCRc4EsA.woff2) format('woff2'); unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; } /* cyrillic */ @font-face { font-family: 'Roboto'; font-style: normal; font-weight: 500; src: url(//fonts.gstatic.com/s/roboto/v18/KFOlCnqEu92Fr1MmEU9fABc4EsA.woff2) format('woff2'); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; } /* greek-ext */ @font-face { font-family: 'Roboto'; font-style: normal; font-weight: 500; src: url(//fonts.gstatic.com/s/roboto/v18/KFOlCnqEu92Fr1MmEU9fCBc4EsA.woff2) format('woff2'); unicode-range: U+1F00-1FFF; } /* greek */ @font-face { font-family: 'Roboto'; font-style: normal; font-weight: 500; src: url(//fonts.gstatic.com/s/roboto/v18/KFOlCnqEu92Fr1MmEU9fBxc4EsA.woff2) format('woff2'); unicode-range: U+0370-03FF; } /* vietnamese */ @font-face { font-family: 'Roboto'; font-style: normal; font-weight: 500; src: url(//fonts.gstatic.com/s/roboto/v18/KFOlCnqEu92Fr1MmEU9fCxc4EsA.woff2) format('woff2'); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EF9, U+20AB; } /* latin-ext */ @font-face { font-family: 'Roboto'; font-style: normal; font-weight: 500; src: url(//fonts.gstatic.com/s/roboto/v18/KFOlCnqEu92Fr1MmEU9fChc4EsA.woff2) format('woff2'); unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; } /* latin */ @font-face { font-family: 'Roboto'; font-style: normal; font-weight: 500; src: url(//fonts.gstatic.com/s/roboto/v18/KFOlCnqEu92Fr1MmEU9fBBc4.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; } /* cyrillic-ext */ @font-face { font-family: 'Roboto'; font-style: normal; font-weight: 900; src: url(//fonts.gstatic.com/s/roboto/v18/KFOlCnqEu92Fr1MmYUtfCRc4EsA.woff2) format('woff2'); unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; } /* cyrillic */ @font-face { font-family: 'Roboto'; font-style: normal; font-weight: 900; src: url(//fonts.gstatic.com/s/roboto/v18/KFOlCnqEu92Fr1MmYUtfABc4EsA.woff2) format('woff2'); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; } /* greek-ext */ @font-face { font-family: 'Roboto'; font-style: normal; font-weight: 900; src: url(//fonts.gstatic.com/s/roboto/v18/KFOlCnqEu92Fr1MmYUtfCBc4EsA.woff2) format('woff2'); unicode-range: U+1F00-1FFF; } /* greek */ @font-face { font-family: 'Roboto'; font-style: normal; font-weight: 900; src: url(//fonts.gstatic.com/s/roboto/v18/KFOlCnqEu92Fr1MmYUtfBxc4EsA.woff2) format('woff2'); unicode-range: U+0370-03FF; } /* vietnamese */ @font-face { font-family: 'Roboto'; font-style: normal; font-weight: 900; src: url(//fonts.gstatic.com/s/roboto/v18/KFOlCnqEu92Fr1MmYUtfCxc4EsA.woff2) format('woff2'); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EF9, U+20AB; } /* latin-ext */ @font-face { font-family: 'Roboto'; font-style: normal; font-weight: 900; src: url(//fonts.gstatic.com/s/roboto/v18/KFOlCnqEu92Fr1MmYUtfChc4EsA.woff2) format('woff2'); unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; } /* latin */ @font-face { font-family: 'Roboto'; font-style: normal; font-weight: 900; src: url(//fonts.gstatic.com/s/roboto/v18/KFOlCnqEu92Fr1MmYUtfBBc4.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; } </style> <script type="text/javascript" src="https://www.gstatic.com/recaptcha/releases/wxAi4AKLXL2kBAvXqI4XLSWS/recaptcha__en.js" nonce="qzB/riJXxiUUlcS0qsqlzg">
</script></head>
<script type="text/javascript" nonce="qzB/riJXxiUUlcS0qsqlzg"> recaptcha.anchor.ErrorMain.init("[\x22ainput\x22,null,null,null,null,null,[1,1,1],\x22Invalid domain for site key\x22,6,null,null,null,[\x22https://www.google.com/intl/en/policies/privacy/\x22,\x22https://www.google.com/intl/en/policies/terms/\x22]]"); </script> `

from tesla.

alandtse avatar alandtse commented on May 18, 2024

It's possible Tesla had tightened their captcha so if it's served to a different host it causes this. Try switching your external address in HA with your internal URL as a workaround.

EDIT: Localhost may be a workaround the recaptcha security. If you're able to use a web browser on your HA machine and change the external url to localhost temporarily, that may be enough.

from tesla.

rberger avatar rberger commented on May 18, 2024

It's possible Tesla had tightened their captcha so if it's served to a different host it causes this. Try switching your external address in HA with your internal URL as a workaround.

I tried that and still getting the same error (the CAPTCHA doesn't show like the OP showed)
I am not running any proxies other than Nabu Casa

from tesla.

alandtse avatar alandtse commented on May 18, 2024

So I investigated this. It looks like Tesla has tightened the captcha security so it compares the captcha page against the page in the browser. This obviously fails the proxy.

This happens due to JavaScript. Because we're using python, there's not really much more we can do to get around it. Python will not process JavaScript and passing it to a browser that isn't looking at auth.tesla.com fails the JavaScript test. While JavaScript could be intercepted and overridden, it's frail and likely to be a problem in the future. There are some discussions here: timdorr/tesla-api#390. The main issue is approaching the api and not getting the initial captcha.

I'll continue to think about how to get around this but we may be done.

from tesla.

ybizeul avatar ybizeul commented on May 18, 2024

Would it be possible to ask for auth and refresh tokens instead ?

from tesla.

ybizeul avatar ybizeul commented on May 18, 2024

Genius. I wanted to test a similar trick, but thought they would compare the whole URL and not just the web site.
I tried something simpler : add on my computer host file auth.tesla.com to my HA LAN address and it doesn't seem to work. Your way through 127.0.0.1 worked though !

from tesla.

ragaimeena avatar ragaimeena commented on May 18, 2024

GENIUS... WORKED.....

from tesla.

hbar98 avatar hbar98 commented on May 18, 2024

I followed those directions and saw the Captcha box. But after I click the "I'm not a robot", and do a captcha image check, I get taken to a 500 Internal Server Error.

What can I do to correct this?

from tesla.

alandtse avatar alandtse commented on May 18, 2024

What can I do to correct this?

Switch back to browser a and refresh.

from tesla.

hbar98 avatar hbar98 commented on May 18, 2024

What can I do to correct this?

Switch back to browser a and refresh.

Did that, still had a 500 Internal Server Error.

So I restarted HA (I use HA core as a virtualized system), double checked the windows hosts file. Add the integration, get the SSO page with captcha error. I copied that into edge, removed the front https:// and nabu casa address for my HA install and added http://auth.tesla.com:8123 to the front. I get the SSO page with correct captcha. I click the OK buttong and immediately get the 500 Internal Service Error. If I go back to browser A and refresh, I get the 500 error.

If I try to re-add it, I get 500 ISE until I restart HA.

If it helps, here's what I put into Browser B:

http://auth.tesla.com:8123/auth/tesla/proxy?config_flow_id=330ef4efb96f4cb38d4ebbfd56c97a86&callback_url=https://[nabu casa address].ui.nabu.casa/auth/tesla/callback?flow_id%3D330ef4efb96f4cb38d4ebbfd56c97a86

from tesla.

alandtse avatar alandtse commented on May 18, 2024

The 500 error is a different error and we'll need logs to help. Please open a new issue and post the requested logs.

It's not clear to me from your description but the HA system must have access to auth.tesla.com so if it's picking up the hosts changes that will break things. The instructions assume your HA and browser machine use different hosts files.

from tesla.

hbar98 avatar hbar98 commented on May 18, 2024

Alrighty! I'll start working on that. Give me a couple of days to work on this.

Just did a quick ping test from my host machine and HA instance. The host machine ping shows the IP of the HA instance, and from HA, when I ping auth.tesla.com, shows an IP of 23.65.224.231

from tesla.

ybizeul avatar ybizeul commented on May 18, 2024

That's expected. Only your local browser should be fooled to go to HA, your HA should be able to reach the actual auth.tesla.com

from tesla.

alandtse avatar alandtse commented on May 18, 2024

So, we're removing Tesla from core and will need to consider what to do with the custom component moving forward . I am looking for input on whether we continue with this workaround using the proxy or switch to requiring a 3rd party application to provide the refresh token. If you have an opinion, please answer here.

from tesla.

zephyrus9MA avatar zephyrus9MA commented on May 18, 2024

Tried the workaround. Captcha appeared OK, but got this:
500 Internal Server Error
Server got itself in trouble

Refreshing Browser A gave the same error. Will try again

from tesla.

juchong avatar juchong commented on May 18, 2024

I can also confirm that the workaround documented above by @alandtse doesn't work when HA is configured to only communicate via HTTPS.

from tesla.

zephyrus9MA avatar zephyrus9MA commented on May 18, 2024

What about logging in with a token? Tesla Token (Android) still works.

from tesla.

heyitsmikey128 avatar heyitsmikey128 commented on May 18, 2024

What about logging in with a token? Tesla Token (Android) still works.

What is a Tesla Token? I have the android app.

from tesla.

zephyrus9MA avatar zephyrus9MA commented on May 18, 2024

Google is your friend.😎😎
"In order to connect to the API {Tesla} uses a token generated from your Tesla.com login credentials. Each time {the app} requests data from your vehicle it authorizes with this token instead of your credentials. ... Your credentials will be used once to obtain the token and then the credentials will be discarded."

from tesla.

rubin110 avatar rubin110 commented on May 18, 2024

I've created a new bug regarding the 500 error. If you're also hitting this bug, either reply with some logs if they differ from mine, or just +1/star/subscribe to it. Please do not reply back with a "me too" comment as it's not helpful.

Also the editing of the hosts file work around is dirty as hell and I applaud @sillyfrog for such a good hack.

bitmoji

from tesla.

zephyrus9MA avatar zephyrus9MA commented on May 18, 2024

Tried latest version (with token) after generating a token and testing it using curl commands. The login failed:

2021-09-11 07:06:51 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration tesla_custom which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2021-09-11 07:06:51 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2021-09-11 07:06:51 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration tesla_cc which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2021-09-11 07:06:51 ERROR (SyncWorker_0) [homeassistant.loader] The custom integration 'tesla_cc' does not have a valid version key (None) in the manifest file and was blocked from loading. See https://developers.home-assistant.io/blog/2021/01/29/custom-integration-changes#versions for more details
2021-09-11 07:06:51 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration tesla_custom which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2021-09-11 07:12:52 ERROR (MainThread) [custom_components.tesla_custom.config_flow] Authentication error: Need oauth credentials 
2021-09-11 07:14:12 ERROR (MainThread) [custom_components.tesla_custom.config_flow] Authentication error: Need oauth credentials 

EDIT: Used wrong token (access instead of refresh)

from tesla.

qJake avatar qJake commented on May 18, 2024

If this custom integration is already configured, will the authentication fail at some point? (i.e. after 45 days when the token expires) - or since it's already configured and has valid tokens, will it just continue to renew them in the background without going through the setup process again?

from tesla.

zephyrus9MA avatar zephyrus9MA commented on May 18, 2024

If this custom integration is already configured, will the authentication fail at some point? (i.e. after 45 days when the token expires) - or since it's already configured and has valid tokens, will it just continue to renew them in the background without going through the setup process again?

Answer appears to be "yes". It failed.
EDIT. Maybe not. I got a new token for another app, so maybe that invalidated the original.

from tesla.

mbrevda avatar mbrevda commented on May 18, 2024

Same here, my token expired. I didn't request a token for anything else

from tesla.

magnussand avatar magnussand commented on May 18, 2024

This trick with updating the hosts file worked for me in September but now my token was invalidated again and this time when I use Broswer B I get:

Access Denied
You don't have permission to access "http://auth.tesla.com/oauth2/v3/authorize?" on this server.

Reference #18........

From http://auth.tesla.com:8123/auth/tesla/proxy?config_flow_id=....

Any ideas?

Edit:
I get the following in the log

2021-11-13 21:19:34 ERROR (MainThread) [aiohttp.server] Error handling request                                                                                                                                     
Traceback (most recent call last):                                                                                                                                                                                 
  File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 61, in map_httpcore_exceptions                                                                                                 
    yield                                                                                                                                                                                                          
  File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 281, in handle_async_request                                                                                                    
    ) = await self._pool.handle_async_request(                                                                                                                                                             
  File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection_pool.py", line 234, in handle_async_request                                                                                      
    response = await connection.handle_async_request(                                                                                                                                         
  File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection.py", line 136, in handle_async_request                                                              
    self.socket = await self._open_socket(timeout)                                                                      
  File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection.py", line 163, in _open_socket                
    return await self._backend.open_tcp_stream(                                                                         
  File "/usr/local/lib/python3.9/site-packages/httpcore/_backends/auto.py", line 44, in open_tcp_stream                 
    return await self.backend.open_tcp_stream(                                                                          
  File "/usr/local/lib/python3.9/site-packages/httpcore/_backends/anyio.py", line 154, in open_tcp_stream               
    stream = await TLSStream.wrap(                                                                                      
  File "/usr/local/lib/python3.9/contextlib.py", line 137, in __exit__                                                  
    self.gen.throw(typ, value, traceback)                                                                               
  File "/usr/local/lib/python3.9/site-packages/httpcore/_exceptions.py", line 12, in map_exceptions                     
    raise to_exc(exc) from None                                                                                                                                                                                    
httpcore.ConnectTimeout                                                                                                                                                       
                                                                                                                        
The above exception was the direct cause of the following exception:                                                                                                                                               
                                                                                                                                                                                                                
Traceback (most recent call last):                                                                                                                                                                                
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request                                                                                                              
    resp = await self._request_handler(request)                                                                                                                                                                    
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 499, in _handle                                                                                                                   
    resp = await handler(request)                                                                                                                                                                          
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 119, in impl                                                                                                 
    return await handler(request)                                                                                                                                             
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)                                                                                       
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 98, in forwarded_middleware            
    return await handler(request)                                                                                       
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 24, in request_context_middleware
    return await handler(request)                                                                                       
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 78, in ban_middleware                        
    return await handler(request)                                                                                       
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 138, in auth_middleware                     
    return await handler(request)                                                                                       
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 135, in handle                                                                                                                         
    result = await result                                                                                                                                                     
  File "/config/custom_components/tesla/config_flow.py", line 325, in wrapped                                           
    return await cls.handler(request, **kwargs)                                                                                                                                                                    
  File "/usr/local/lib/python3.9/site-packages/authcaptureproxy/auth_capture_proxy.py", line 382, in all_handler                                                                                                   
    resp = await getattr(self.session, method)(site, headers=headers)                                                   
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1740, in get                                     
    return await self.request(                                                                                          
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1494, in request                                 
    response = await self.send(                                                                                         
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1586, in send                                    
    response = await self._send_handling_auth(                                                                          
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1616, in _send_handling_auth                                                                                                                
    response = await self._send_handling_redirects(                                                                                                                           
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1655, in _send_handling_redirects                
    response = await self._send_single_request(request, timeout)                                                        
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1699, in _send_single_request                    
    ) = await transport.handle_async_request(                                                                           
  File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 276, in handle_async_request         
    (                                                                                                                   
  File "/usr/local/lib/python3.9/contextlib.py", line 137, in __exit__                                                  
    self.gen.throw(typ, value, traceback)                                                                               
  File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 78, in map_httpcore_exceptions       
    raise mapped_exc(message) from exc                                                                                  
httpx.ConnectTimeout

from tesla.

zephyrus9MA avatar zephyrus9MA commented on May 18, 2024

This trick with updating the hosts file worked for me in September but now my token was invalidated again and this time when I use Broswer B I get:

Access Denied
You don't have permission to access "http://auth.tesla.com/oauth2/v3/authorize?" on this server.

Reference #18........

From http://auth.tesla.com:8123/auth/tesla/proxy?config_flow_id=....

Any ideas?

Edit: I get the following in the log

2021-11-13 21:19:34 ERROR (MainThread) [aiohttp.server] Error handling request                                                                                                                                     
Traceback (most recent call last):                                                                                                                                                                                 
  File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 61, in map_httpcore_exceptions                                                                                                 
    yield                                                                                                                                                                                                          
  File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 281, in handle_async_request                                                                                                    
    ) = await self._pool.handle_async_request(                                                                                                                                                             
  File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection_pool.py", line 234, in handle_async_request                                                                                      
    response = await connection.handle_async_request(                                                                                                                                         
  File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection.py", line 136, in handle_async_request                                                              
    self.socket = await self._open_socket(timeout)                                                                      
  File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection.py", line 163, in _open_socket                
    return await self._backend.open_tcp_stream(                                                                         
  File "/usr/local/lib/python3.9/site-packages/httpcore/_backends/auto.py", line 44, in open_tcp_stream                 
    return await self.backend.open_tcp_stream(                                                                          
  File "/usr/local/lib/python3.9/site-packages/httpcore/_backends/anyio.py", line 154, in open_tcp_stream               
    stream = await TLSStream.wrap(                                                                                      
  File "/usr/local/lib/python3.9/contextlib.py", line 137, in __exit__                                                  
    self.gen.throw(typ, value, traceback)                                                                               
  File "/usr/local/lib/python3.9/site-packages/httpcore/_exceptions.py", line 12, in map_exceptions                     
    raise to_exc(exc) from None                                                                                                                                                                                    
httpcore.ConnectTimeout                                                                                                                                                       
                                                                                                                        
The above exception was the direct cause of the following exception:                                                                                                                                               
                                                                                                                                                                                                                
Traceback (most recent call last):                                                                                                                                                                                
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request                                                                                                              
    resp = await self._request_handler(request)                                                                                                                                                                    
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 499, in _handle                                                                                                                   
    resp = await handler(request)                                                                                                                                                                          
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 119, in impl                                                                                                 
    return await handler(request)                                                                                                                                             
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)                                                                                       
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 98, in forwarded_middleware            
    return await handler(request)                                                                                       
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 24, in request_context_middleware
    return await handler(request)                                                                                       
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 78, in ban_middleware                        
    return await handler(request)                                                                                       
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 138, in auth_middleware                     
    return await handler(request)                                                                                       
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 135, in handle                                                                                                                         
    result = await result                                                                                                                                                     
  File "/config/custom_components/tesla/config_flow.py", line 325, in wrapped                                           
    return await cls.handler(request, **kwargs)                                                                                                                                                                    
  File "/usr/local/lib/python3.9/site-packages/authcaptureproxy/auth_capture_proxy.py", line 382, in all_handler                                                                                                   
    resp = await getattr(self.session, method)(site, headers=headers)                                                   
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1740, in get                                     
    return await self.request(                                                                                          
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1494, in request                                 
    response = await self.send(                                                                                         
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1586, in send                                    
    response = await self._send_handling_auth(                                                                          
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1616, in _send_handling_auth                                                                                                                
    response = await self._send_handling_redirects(                                                                                                                           
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1655, in _send_handling_redirects                
    response = await self._send_single_request(request, timeout)                                                        
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1699, in _send_single_request                    
    ) = await transport.handle_async_request(                                                                           
  File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 276, in handle_async_request         
    (                                                                                                                   
  File "/usr/local/lib/python3.9/contextlib.py", line 137, in __exit__                                                  
    self.gen.throw(typ, value, traceback)                                                                               
  File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 78, in map_httpcore_exceptions       
    raise mapped_exc(message) from exc                                                                                  
httpx.ConnectTimeout

Why not just use the refresh token? Has been working well for me for a month or 2.

from tesla.

magnussand avatar magnussand commented on May 18, 2024

Why not just use the refresh token? Has been working well for me for a month or 2.

This I have missed... But...

I have installed the Auth Token app for Android and cleared the cache in my browser and also reinstalled the Tesla Custom Component version 1.3.1.

But when searching it seems like I get the wrong version when trying to configure the integration?
According to this comment it looks like I should get a page that ask for email and refresh token, but I get the old proxy which ask for username and password
image

What have I missed?

from tesla.

zephyrus9MA avatar zephyrus9MA commented on May 18, 2024

Did you try all the items in the thread you reference? Looks like several of us had success uninstalling/reinstalling HACS.

from tesla.

EvTheFuture avatar EvTheFuture commented on May 18, 2024

Did you try all the items in the thread you reference? Looks like several of us had success uninstalling/reinstalling HACS.

  • I uninstalled the integration.
  • Restarted Home Assistant.
  • Cleared the cache in the browser.
  • Reinstalled the Tesla component
  • Restarted Home Assistant
  • Added the integration.

I can try to uninstall hacks, but that will be Tomorow.

But just to confirm, this should work with version 1.3.1 right?

from tesla.

EvTheFuture avatar EvTheFuture commented on May 18, 2024

I got it to work.

It seems like there was two Tesla directories inside /config/custom_components

One named tesla_custom and one tesla. I uninstalled the Tesla custom integration which also removed tesla_custom however the Tesla directory didn't seem to belong to an installed custom component.

  • I deleted the Tesla directory with rm -rf /config/custom_component/tesla
  • I restarted Home Assistant
  • Then I added version 1.3.1 of the Tesla Custom Integration
  • Restarted Home Assistant

Then I got the proper UI in the browser when I added the integration in Configuration -> Integrations -> + Add Integration

Thank you for pointing me in the right direction and I hope this helps if someone else have the same problem in the future.

from tesla.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.