-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Any suggestions? #44
Comments
<ClientResponse(https://owner-api.teslamotors.com/oauth/token) [400 Bad Request]> |
In my experience, errors like this come and go. They seem to play with the API from time to time. I think there is a new problem now though with Captcha being added as discussed here: timdorr/tesla-api#390 |
I managed to work around the captcha by grabbing a token in Postman using the built in authentication stuff, then popping it in a json file and removing direct user and pass. Works for MFA too as you're just logging in a browser as you would in the app - and the tokens refresh anyway, so should never have to do it again hypothetically. Settings for Postman that worked: Client secret:c7257eb71a564034f9419ee651c7d0e5f7aa6bfbd18bafb5c5c033b093bb2fa3 |
This is the rest. The It looks like this: {"resfresh_token": "", "access_token": "", "expires_in": 28800, "created_at": 1622326394.014721} async def save_token(token):
open("token_file.json", "w").write(token)
async def load_token():
try:
with open('token_file.json', "r") as f:
return f.read()
except IOError:
await save_token(START_TOKEN)
return await load_token()
async def getreserve():
token = await load_token()
client = TeslaApiClient(token=token, on_new_token=save_token) |
I deleted my previous response out of embarrassment but thank very much for holding my hand. I don't know why I couldn't fumble my way through the UI to find this! |
I find it to be unintuitive... could be a better UI . There is a problem I've come across now that the code does not refresh the tokens properly, gives an |
well that's unfortunate. I think I maybe saw this when I first wrote my script, but probably just attributed to my lack of understanding/knowledge, and just pass the credentials each time (the script only has 1 user - me!) |
The auth token works fine, just when it expires the refresh step fails. |
Thanks @jakkaj, your token suggestion is working for me and but I'm also seeing the refresh step failing.
The "issued to another client" makes me wonder if the |
I was able to refresh the token! I used I can make a proper PR, but for now my changes are below:
|
This project seems to handle the captcha pretty well, might be useful to lift some of their work: |
@fracai sweet! |
Yeah it is a lot. Probably way more than needed. The built in interactive login (kicks out to system web browser) and token refresh handling seems pretty solid though. Not really suggesting to duplicate all the work, but since it all works it might be a useful resource for getting the flows right. |
The thing I like best about built in flows is that no need to update things
when Telsla changes their flows a little.
…On Tue, Sep 28, 2021 at 9:17 AM Jesse Campbell ***@***.***> wrote:
Yeah it is a lot. Probably way more than needed. The built in interactive
login (kicks out to system web browser) and token refresh handling seems
pretty solid though. Not really suggesting to duplicate all the work, but
since it all works it might be a useful resource for getting the flows
right.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#44 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABH32NVM3NUGHLHPIWI5QCTUED3RZANCNFSM45XWK3OQ>
.
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&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
I am getting the error below. Any suggestions?
Traceback (most recent call last):
File "/Users/jackkorber/Desktop/Python/GetPowerwallCapacity/powerwallCapacity.py", line 31, in
asyncio.run(main())
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/runners.py", line 43, in run
return loop.run_until_complete(main)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 608, in run_until_complete
return future.result()
File "/Users/jackkorber/Desktop/Python/GetPowerwallCapacity/powerwallCapacity.py", line 12, in main
energy_sites = await client.list_energy_sites()
File "/Users/jackkorber/Desktop/Python/GetPowerwallCapacity/tesla_api/init.py", line 123, in list_energy_sites
for product in await self.get("products") if "energy_site_id" in product]
File "/Users/jackkorber/Desktop/Python/GetPowerwallCapacity/tesla_api/init.py", line 91, in get
await self.authenticate()
File "/Users/jackkorber/Desktop/Python/GetPowerwallCapacity/tesla_api/init.py", line 81, in authenticate
expiry_time = timedelta(seconds=self._token["expires_in"])
KeyError: 'expires_in'
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7fa22a881ac0>
Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x7fa22a8a5520>, 0.69530855)]']
connector: <aiohttp.connector.TCPConnector object at 0x7fa22a881af0>
The text was updated successfully, but these errors were encountered: