mlowijs / tesla_api

Lightweight Python API client for the Tesla API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Possible new login issue

scienceintheshed opened this issue · comments

This just started this morning...currently happening on two separate machines.

Python 3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, 15:37:30) [MSC v.1927 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.

=================== RESTART: C:\Python\Powerwall 3\tesla5%.py ==================
Traceback (most recent call last):
File "C:\Python\Powerwall 3\tesla5%.py", line 14, in
asyncio.run(main())
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\lib\asyncio\base_events.py", line 616, in run_until_complete
return future.result()
File "C:\Python\Powerwall 3\tesla5%.py", line 7, in main
energy_sites = await client.list_energy_sites()
File "C:\Python\Powerwall 3\tesla_api_init_.py", line 174, in list_energy_sites
for product in await self.get("products") if "energy_site_id" in product]
File "C:\Python\Powerwall 3\tesla_api_init_.py", line 142, in get
await self.authenticate()
File "C:\Python\Powerwall 3\tesla_api_init_.py", line 130, in authenticate
self._token = await self.get_new_token()
File "C:\Python\Powerwall 3\tesla_api_init
.py", line 90, in _get_new_token
redirect_location = resp.headers["Location"]
KeyError: 'Location'

With MFA using old bearer token is still working for TeslaTasks.

AFAIK TeslaTasks connects to a vehicle. I'm using this on a Powerwall and there is no option for me to setup MFA through the Powerwall app.

You setup MFA on Tesla's website, not via the app.

MFA does not change the fact that the new code has stopped working.

All I can say is that TT experiences no problems, both with actually logging in (using MFA) and using the obtained long lived token.

It seems your error is when obtaining the Location header after the login. You could give my Java implementation a try, if you're up to it, to see if that also has the problem. That is what TT uses.
https://github.com/tbee/teslaApi/blob/main/src/main/java/org/tbee/tesla/TeslaMFALogic.java#L310

Digging deeper I'm finding that I'm getting a 403 response when trying to get a new token even though I can authenticate locally using the gateway ip address and same credentials, so something has changed at Tesla.

Same here. Getting a 403 response.

I've been getting a 500 response since a few weeks now on the request for the factor id's. And have not been able to figure out why. I see that the process is okay (compared to what happens in a browser). The actual commands do still work, it's just the login process.