Skip to content
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

regular expression in line 1050 of Vehicle/TeslaAPI.py needs to be changed #566

Open
GMerg opened this issue Mar 7, 2024 · 2 comments
Open

Comments

@GMerg
Copy link

GMerg commented Mar 7, 2024

          I have noticed a bug which might be helpful in this case:

original code (line 1050 in Vehicle/TeslaAPI.py)

        if isinstance(url, bytes):
            url = url.decode("UTF-8")
        code = re.search(r"code=(.+)&state=(.+)", url)

This assumes that after the "state" variable, nothing is there. But that was not the case for me. It had additinal parameters in it that got added as "state" later on and so the requests always failed. This regular expression has to optimized to skip additinal parameters. I also would suggest to change it in case the reply changes (state before code in URL).

Originally posted by @GMerg in #564 (comment)

@whisdol
Copy link

whisdol commented Mar 7, 2024

This certainly explains why pasting the URL never works and the manual access & refresh token input is required.

My regex prowess is limited, but Line 1053 should then be in the simplest case:

code2 = re.search(r"code=(.+)&state=(.+)&*", url)

But it's a better idea to make this more generic and just read code and state separately.

@dtiefnig
Copy link

There are sure better ways to write this, but as the value of the state parameter (i.e. code.group(2) as returned by re and written to the log) is never used, what difference does it make? Is there really an issue with saving the token? Might be something else then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants