Token refresh is not working for me #130
Replies: 8 comments 4 replies
-
Additional info. I turned on debug logging on the orangePI. It tries to refresh the token, but this is what happens:
|
Beta Was this translation helpful? Give feedback.
-
I had the same problem and could solve it by going back to older versions of some of the python packages used by teslapy. Have a look at this issue: Fabian |
Beta Was this translation helpful? Give feedback.
-
Hi Fabian,That sounds really promising. I will test this asap.Cheers,HansOp 6 jun. 2023 om 16:20 heeft fbphysik ***@***.***> het volgende geschreven:
I had the same problem and could solve it by going back to older versions of some of the python packages used by teslapy. Have a look at this issue:
#128
Fabian
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Works like a charm. Thanks a million!!!!!!
… On 6 Jun 2023, at 16:20, fbphysik ***@***.***> wrote:
I had the same problem and could solve it by going back to older versions of some of the python packages used by teslapy. Have a look at this issue:
#128 <#128>
Fabian
—
Reply to this email directly, view it on GitHub <#130 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABKBYTW7LVBBRTU2WCYSDBTXJ44CDANCNFSM6AAAAAAYQHJAUE>.
You are receiving this because you authored the thread.
|
Beta Was this translation helpful? Give feedback.
-
I did not investigate that. Op 23 jun. 2023 om 12:59 heeft Tim Dorssers ***@***.***> het volgende geschreven:
Do we know which of those packages is the culprit?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I just checked: The other downgrades ('certifi', 'charset-normalizer', 'websocket-client') I mentioned in #128 don't seem to be necessary. |
Beta Was this translation helpful? Give feedback.
-
I can't reproduce this. I tried using an expired token, to trigger auto refresh but I don't get a 403. Is it really needed to have a script running for over 8 hours to trigger this? I am looking for a minimal script to reproduce this |
Beta Was this translation helpful? Give feedback.
-
No, there is no long running script necessary to reproduce the error. My steps are:
import teslapy
tesla = teslapy.Tesla('XX@YY.ZZ')
if not tesla.authorized:
print('Use browser to login. Page Not Found will be shown at success.')
print('Open this URL: ' + tesla.authorization_url())
tesla.fetch_token(authorization_response=input('Enter URL after authentication: '))
vehicles = tesla.vehicle_list()
print(vehicles[0])
tesla.close() Python version is 3.9.2, running on a Debian Bullseye system. Let me know if you need any more information or if I can check things for you or send you some debug logs etc. |
Beta Was this translation helpful? Give feedback.
-
I have obtained a token (cache.json) via command
python3 cli.py -e <my mail address>
I copied the cache.json to the orange zero headless computer where it functions for a while (can interact with my Tesla).
After a while (hours) I get this exception:
Exception during setting of the current: Traceback (most recent call last): File "/home/pi/venv/lib/python3.9/site-packages/requests_oauthlib/oauth2_session.py", line 483, in request url, headers, data = self._client.add_token( File "/home/pi/venv/lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 217, in add_token raise TokenExpiredError() oauthlib.oauth2.rfc6749.errors.TokenExpiredError: (token_expired) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/pi/net_balancer-main/src/service/tesla_energy_consumer.py", line 129, in start_consuming self.__set_charge_current(new_charging_current) File "/home/pi/net_balancer-main/src/service/tesla_energy_consumer.py", line 278, in __set_charge_current self.vehicle.command("CHARGING_AMPS",charging_amps=amps) File "/home/pi/net_balancer-main/src/teslapy/__init__.py", line 711, in command response = self.api(name, **kwargs).get('response') File "/home/pi/net_balancer-main/src/teslapy/__init__.py", line 488, in api return self.tesla.api(name, {'vehicle_id': self['id_s']}, **kwargs) File "/home/pi/net_balancer-main/src/teslapy/__init__.py", line 369, in api return self.request(endpoint['TYPE'], uri, serialize, File "/home/pi/net_balancer-main/src/teslapy/__init__.py", line 150, in request response = super(Tesla, self).request(method, url, **kwargs) File "/home/pi/venv/lib/python3.9/site-packages/requests_oauthlib/oauth2_session.py", line 502, in request token = self.refresh_token( File "/home/pi/net_balancer-main/src/teslapy/__init__.py", line 249, in refresh_token super(Tesla, self).refresh_token(token_url, **kwargs) File "/home/pi/venv/lib/python3.9/site-packages/requests_oauthlib/oauth2_session.py", line 452, in refresh_token self.token = self._client.parse_request_body_response(r.text, scope=self.scope) File "/home/pi/venv/lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 427, in parse_request_body_response self.token = parse_token_response(body, scope=scope) File "/home/pi/venv/lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 441, in parse_token_response validate_token_parameters(params) File "/home/pi/venv/lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 451, in validate_token_parameters raise MissingTokenError(description="Missing access token parameter.") oauthlib.oauth2.rfc6749.errors.MissingTokenError: (missing_token) Missing access token parameter.
It looks as if the auto refresh is not happening.
I have no clue what I am doing wrong here. Does anybody have a suggestion?
Beta Was this translation helpful? Give feedback.
All reactions