sdague/mychevy

Exception in page.login(): initial_url.query is unexpectedly empty

ph1l opened this issue · 1 comments

ph1l commented
  • mychevy version: v2.1.1
  • Python version: Python 3.7.3 (default, Jan 22 2021, 20:04:44)
  • Operating System: Debian GNU/Linux 10 (buster)

Description

Just trying to set this up for my new 2022 Bolt EV! Looks like a connection problem trying to login?

What I Did

elektron@x200:~/code/mychevy$ mychevy-debug --config ./config.ini --verbose
Logging in... this takes a bit
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): my.chevrolet.com:443
DEBUG:urllib3.connectionpool:https://my.chevrolet.com:443 "GET /home HTTP/1.1" 200 2844
Traceback (most recent call last):
  File "/usr/local/bin/mychevy-debug", line 11, in <module>
    load_entry_point('mychevy', 'console_scripts', 'mychevy-debug')()
  File "/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/elektron/code/mychevy/mychevy/debug.py", line 31, in main
    page.login()
  File "/home/elektron/code/mychevy/mychevy/mychevy.py", line 254, in login
    nonce = urllib.parse.parse_qs(initial_url.query).get("nonce")[0]
TypeError: 'NoneType' object is not subscriptable

Additional debug added:

elektron@x200:~/code/mychevy$ git diff
diff --git a/mychevy/mychevy.py b/mychevy/mychevy.py
index 7fefe27..10609c7 100644
--- a/mychevy/mychevy.py
+++ b/mychevy/mychevy.py
@@ -251,6 +251,7 @@ class MyChevy(object):
         # It doesn't like an empty session so load the login page first.
         r = self.session.get(get_url("home", self.country), timeout=TIMEOUT)
         initial_url = urllib.parse.urlparse(r.request.url)
+        _LOGGER.debug("initial_url: %s", initial_url)
         nonce = urllib.parse.parse_qs(initial_url.query).get("nonce")[0]
 
         _LOGGER.debug("Initial URL %s, Nonce %s", initial_url, nonce)
elektron@x200:~/code/mychevy$ mychevy-debug --config ./config.ini --verbose
Logging in... this takes a bit
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): my.chevrolet.com:443
DEBUG:urllib3.connectionpool:https://my.chevrolet.com:443 "GET /home HTTP/1.1" 200 2845
DEBUG:mychevy.mychevy:initial_url: ParseResult(scheme='https', netloc='my.chevrolet.com', path='/home', params='', query='', fragment='')
Traceback (most recent call last):
  File "/usr/local/bin/mychevy-debug", line 11, in <module>
    load_entry_point('mychevy', 'console_scripts', 'mychevy-debug')()
  File "/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/elektron/code/mychevy/mychevy/debug.py", line 31, in main
    page.login()
  File "/home/elektron/code/mychevy/mychevy/mychevy.py", line 255, in login
    nonce = urllib.parse.parse_qs(initial_url.query).get("nonce")[0]
TypeError: 'NoneType' object is not subscriptable

It unfortunately looks like they changed the front page again, so the way to get into the environment fails again.

I appears that https://github.com/samrum/OnStarJS and https://github.com/mikenemat/gm-onstar-probe have figured out a more direct route to the onstar API. That's probably worth investigating.