TeslaPy icon indicating copy to clipboard operation
TeslaPy copied to clipboard

(missing_token) Missing access token parameter.

Open behconsci opened this issue 1 year ago • 14 comments

hey Tim, thanks for this great library!!! I am getting this issue below. It works well in my localhost, but on server (Debian) it is failing with this error:

(missing_token) Missing access token parameter.

image image image image

behconsci avatar May 21 '23 05:05 behconsci

This error means that oauthlib doesn't get an access token back from the Tesla server. The body is actually HTML with an access denied error instead of a JSON response.

tdorssers avatar May 21 '23 09:05 tdorssers

yep, I see that. But do you know why it is happening? it seems TLS is old on server? localhost is working well. Strange

Tim Dorssers @.***> schrieb am So. 21. Mai 2023 um 11:43:

This error means that oauthlib doesn't get an access token back from the Tesla server. The body is actually HTML with an access denied error instead of a JSON response.

— Reply to this email directly, view it on GitHub https://github.com/tdorssers/TeslaPy/issues/128#issuecomment-1556132800, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACPA4M5URDTIRP2T6A7VUH3XHHPT7ANCNFSM6AAAAAAYJF3NUI . You are receiving this because you authored the thread.Message ID: @.***>

behconsci avatar May 21 '23 09:05 behconsci

Hi. I have the same issue. Everything worked fine until today I set up a new virtual environment, in which I installed teslapy with all necessary dependencies. Now I keep getting the "Missing access token parameter". Maybe something goes wrong with the current version of one of the packages teslapy depends on?

buehlerfabian avatar May 27 '23 19:05 buehlerfabian

I deployed on different servers (debian, ubuntu..) and still no luck. I have TeslaPy==2.7.0 both in my localhost and on server. localhost works fine, but server doesn't. what are we missing here?

behconsci avatar May 29 '23 07:05 behconsci

I tried different versions for TeslaPy and also for the dependent packages, no change. Providing a refresh token obtained from a third party app didn't work either. Always the same error: MissingTokenError raised from oauthlib/oauth2/rfc6749/parameters.py", line 451, in validate_token_parameters.

buehlerfabian avatar May 29 '23 07:05 buehlerfabian

what we are doing is a pure "man in the middle attack"? :D but then localhost is still working. I suspect, the scope is the issue, maybe? instead of offline_access maybe online_access .. but just a guess

behconsci avatar May 29 '23 07:05 behconsci

but then localhost is still working.

Lucky for you. Here nothing is working, neither server nor localhost.

buehlerfabian avatar May 29 '23 07:05 buehlerfabian

damn it. time for tesla sso auth for third parties.

behconsci avatar May 29 '23 08:05 behconsci

I think I may have found a solution that works for me: using the following (older) package versions I can log in again without the "Missing token error"

certifi = "2022.9.24" charset-normalizer = "2.1.1" requests = "2.28.1" urllib3 = "1.26.12" websocket-client = "1.4.1"

With one or more of these packages the newer (current) versions seem to cause the trouble.

buehlerfabian avatar Jun 01 '23 18:06 buehlerfabian

Aaah thanks man. I will try out tomorrow morning.

behconsci avatar Jun 01 '23 19:06 behconsci

This saved my day. Week Month

HansKappert avatar Jun 06 '23 16:06 HansKappert

Hey @fbphysik

thank you so much for the tip !

had the same problem, but it was solved only by downgrading charset-nromalize and requests to the aforementioned versions, I did not have to touch the others

if that's important : I"m working in an up-to-date dockerised Domoticz where I had :

  • requests 2.31.0 (downgraded to 2.28.1)
  • certifi-2023.7.22
  • charset_normalizer-3.2.0 (downgraded to 2.1.1)
  • urllib3 2.0.4
  • websocket-client 1.6.2 On my other computer it works with :
  • requests 2.25.1
  • certifi 2020.6.20
  • urllib3 1.26.5
  • websocket-client 1.5.1 (charset_normalize is nowhere to be found)

If I had a guess that would be to blame a recent requests update

(thank you so much for teslapy btw :) )

Refhi avatar Aug 25 '23 20:08 Refhi

I believe the combination of urllib3 2.0 and Python <3.10 is causing issues. Either upgrade Python to 3.10+ or downgrade urllib3 to 1.26.x. Please let me now if this works for you.

tdorssers avatar Aug 26 '23 20:08 tdorssers

I'm sorry it will be difficult for me to do more testing, though in my dockerized environment it works properly with python 3.9 and urlib 2.0.4 It broke with requests 2.31/charset_normalize 3.2, but worked again with downgrading to requests 2.28.1/charset_normalize 2.1.1 if that helps here's my pip list (where TeslaPy is working properly) :

Python 3.9.2 (default, Feb 28 2021, 17:03:44) Package Version certifi 2023.7.22 charset-normalizer 2.1.1 idna 3.4 oauthlib 3.2.2 pip 20.3.4 requests 2.28.1 requests-oauthlib 1.3.1 setuptools 52.0.0 TeslaPy 2.8.0 urllib3 2.0.4 websocket-client 1.6.2 wheel 0.34.2

Hope that'll help a bit

Refhi avatar Aug 27 '23 09:08 Refhi