Comments (19)
Yes this version supports the streaming API as well. I will package this version shortly and make it available on pypi.
from teslapy.
It looks like Tesla has enabled captcha again, but not for every user-agent it seems. The captcha image is displayed in the systems default web browser. You can override this by specifying your own captcha_solver function.
Please be aware that captcha is not MFA. When you use cli.py the MFA code is entered at the Passcode:
prompt, not at the Captcha:
prompt, which comes first.
from teslapy.
I'm looking for help with understanding an error I'm getting:
Traceback (most recent call last):
File "julia2.py", line 387, in
tesla.fetch_token()
File "/home/pi/.local/lib/python2.7/site-packages/teslapy/init.py", line 180, in fetch_token
raise ValueError('Credentials rejected')
ValueError: Credentials rejected
I was previously using teslajson until the problem with captcha occured a little while ago. I then experimented with teslapy and set up a test program which was just your example code but in a while loop to log data to a file. As Tesla backed out the change I just left my original teslajson code running until captcha was reinstated a few days ago.
The thing is, that teslapy test program is still working fine.
And if I start an interactive python session and enter the teslapy statements manually, that works too - even while the other code is running (same PC and user).
I rewrote my original program to replace teslajson with teslapy and even though I cannot see anything in it that differs from my working test program (it just does a lot more with the data) it always fails.
The system I'm using is a Raspberry Pi 4 with:
Linux rpi4 5.10.17-v7l+ #1421 SMP Thu May 27 14:00:13 BST 2021 armv7l GNU/Linux
Python 2.7.16 (default, Oct 10 2019, 22:02:15)
[GCC 8.3.0] on linux2
TeslaPy 1.2.0
I tried installing everything on an alternative system running::
Linux rpi3 4.19.58-v7+ #1245 SMP Fri Jul 12 17:25:51 BST 2019 armv7l GNU/Linux
Python 2.7.13 (default, Sep 26 2018, 18:42:22)
[GCC 6.3.0 20170516] on linux2
TeslaPy 1.3.0
On this system I get a CAPTCHA prompt from my main program, the interactive python session and my test teslapy code.
Is it possible that the token generated for my test program when CAPTCHA was not active is still in effect?
If this is the case, will it still continue to work if I upgrade to TeslaPy 1.3.0?
Any help will be gratefully received.
from teslapy.
ps: cache.json shows (I think) the bearer token was created 2021-06-19 13:23:52 and will expire 2021-08-03 13:23:52.
from teslapy.
Yes the captcha is only required when there is no bearer token in cache.json present for your email. Once the bearer token is there, the module will refresh the token automatically. So on the 3rd of August the token will be refreshed and you do not need to enter the captcha again.
Version 1.3.0 is the first version that supports captcha, and upgrading to 1.3.0 should not break anything.
from teslapy.
I am on 1.3.0 but
File "/Users/server/Library/Python/2.7/lib/python/site-packages/teslapy/__init__.py", line 170, in fetch_token
raise ValueError('Credentials rejected')
What exactly do I have to do to make it work again?
from teslapy.
The most likely cause is that the captcha verification code is missing. So either you use a cache.json file with valid token, or you need to pass the authentication phase including captcha verification. Now, the captcha image will be shown in the systems default web browser. If you don't have a graphical interface, then you can use the solution presented in issue #25.
from teslapy.
the cli and menu scripts are no longer asking for a Captcha, but I think im blocked for some other reason now...
Max retries exceeded with url: /oauth2/v3/authorize?response_type=code&client_id=ownerapi&redirect_uri=https%3A%2F%2Fauth.tesla.com%2Fvoid%2Fcallback&scope=openid+email+offline_access&state=
(Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0xb5c92830>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))
from teslapy.
It is not working automatically. As far as I understand I have to enter the captcha manually. But it isn't even downloaded.
This kind of breaks the functionality.
How do other Apps solve this issue? Ask the user for the captcha?
def solve_captcha(svg):
with open('/home/TeslaPy/captcha.svg', 'wb') as f:
f.write(svg)
f.close()
return input('Captcha: TEST')
from teslapy.
Yes the captcha is only required when there is no bearer token in cache.json present for your email. Once the bearer token is there, the module will refresh the token automatically. So on the 3rd of August the token will be refreshed and you do not need to enter the captcha again.
Version 1.3.0 is the first version that supports captcha, and upgrading to 1.3.0 should not break anything.
Hi, thanks for that. Once I realised that cache.json had to be in the working directory everything fell into place and works just fine. Also, thanks for the pointer to the code for handling CAPTCHA in a non-GUI scenario.
Best regards.
from teslapy.
@dawiinci any luck? I am not being returned a Captcha, and not using a GUI so kinda lost here. Is there a standalone script that creates the token?
from teslapy.
Unfortunately not. I hope there will be an integrated way at some time.
Even better would be an API without captcha. Doesn't make sense to me, because you have to refresh the token every few weeks. I think we all somehow rely on the system to just work "forever".
I am wondering how commercial apps are doing this.
from teslapy.
It appears that Tesla requires captcha only for certain User-Agents. The wrong User-Agent was sent during authentication and this is fixed in 6c0fda4. I no longer get a captcha presented with this code fix.
This module only asks for a captcha if it is a required field on the login form, which is provided by Tesla. The commercial app of Tesla doesn't get this captcha because it's a trusted User-Agent. The Tesla App only required the captcha for a few days (May 28-30 or so) and then it magically disappeared.
from teslapy.
Thanks, that sounds good.
By just replacing the files I get this:
import websocket # websocket-client v0.49.0 up to v0.58.0 is not supported
ImportError: No module named websocket
After installing pip install websocket-client it works.
The change is not available with "pip install teslapy" yet. I guess the websocket is a new thing?
from teslapy.
The issue came back:
ValueError: Credentials rejected. Captcha is required. Captcha does not match
from teslapy.
yep, i have this issue too... :(
from teslapy.
Please give the fix in ebcef52 a try!
from teslapy.
Unfortunately it still asks for a Captcha and opens the browser.
Script Error tesla_connect.py: EOF when reading a line
Script Error Exception Traceback (most recent call shown last):
tesla_connect.py, line 18, at top level
File "/Users/server/Library/Python/2.7/lib/python/site-packages/teslapy/__init__.py", line 205, in fetch_token
form['captcha'] = self.captcha_solver(response.content)
File "/Users/server/Library/Python/2.7/lib/python/site-packages/teslapy/__init__.py", line 319, in _solve_captcha
return input('Captcha: ')
EOFError: EOF when reading a line
I just replaced the three files in teslapy folder. It should work without captchas, right?
from teslapy.
No the captcha is required at this time. The auth server 'rejects' the first login attempt and asks for a captcha, teslapy now handles this and allows successful login.
from teslapy.
Related Issues (20)
- 429 on every sync_wake_up() call HOT 3
- last_seen() raises "Timestamp is in the future" error HOT 3
- No longer able to set Powerwall to self_consumption mode HOT 6
- Percentage Charged not updating on get_battery_data()
- Preconditioning Battery
- Authorization broken -> Always getting "Access Denied" HOT 1
- Solar panel power only updates sporadically HOT 2
- Fails to work when run in a daemon process. HOT 2
- 410 error on get_battery_data HOT 15
- 400 Client Error: time_of_use_settings
- latitude and longitude are not in drive_state HOT 3
- Selenium blocked by Tesla HOT 2
- Move to Fleet API and Tesla Vehicle Command SDK HOT 5
- I get an InvalidSchema("No connection adapters were found for 'https://owner-api.teslamotors.com/api/1/vehicles/) Exception when using vehicle.get_vehicle_data() HOT 1
- Powerwall function get_battery_data not working HOT 1
- Not able to login HOT 6
- It seems get_charge_history() API URI is no longer working? Returns 400 HOT 2
- Seems like the teslapy is no longer working with the new Tesla APIs HOT 58
- drive_state does not have latitude and longitude
- shift_state and speed stay None even during driving
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from teslapy.