pycarwings2 icon indicating copy to clipboard operation
pycarwings2 copied to clipboard

Canada NCI login fails "INVALID PARAMS" from HTTP Response Body

Open fermulator opened this issue 4 years ago • 21 comments

Good day,

Initially tried this via https://www.home-assistant.io/integrations/nissan_leaf/, however it didn't work with:

Feb 08 16:45:44 hass hass[2545]: 2020-02-08 16:45:44 ERROR (SyncWorker_9) [pycarwings2.pycarwings2] carwings error INVALID PARAMS: -2010
Feb 08 16:45:44 hass hass[2545]: 2020-02-08 16:45:44 ERROR (SyncWorker_9) [homeassistant.components.nissan_leaf] An unknown error occurred while connecting to Nissan: <(snipped/lost)

Reproduced it with my account hitting Canada NCI portal using latest pycarwings2:

As per the README.md, did the basic install, and copied down some examples w/ my_config.ini.

$ python3 --version
Python 3.6.8

$ pip3 list | egrep "pycar|chardet|urllib3"
chardet                  3.0.4                 
pycarwings2              2.9                   
urllib3                  1.25.8                
~/.local/lib/python3.6/site-packages/pycarwings2/examples$ ll
total 44
drwxrwxr-x 2 fermulator fermulator 4096 Feb  8 20:05 ./
drwxrwxr-x 4 fermulator fermulator 4096 Feb  8 19:57 ../
-rw-rw-r-- 1 fermulator fermulator  129 Feb  8 19:57 config.ini
-rwxrwxr-x 1 fermulator fermulator 3167 Feb  8 20:03 get-leaf-info.py*
-rw-rw-r-- 1 fermulator fermulator  148 Feb  8 19:59 my_config.ini

Had to tweak get-leaf-info.py to hit my python3 directly (not env python), otherwise it is left unmodified.

After that, it ran, and repro'd the problem:

~/.local/lib/python3.6/site-packages/pycarwings2/examples$ ./get-leaf-info.py 
DEBUG:root:login = (SNIP), password = (snip), region = NCI
Prepare Session
Login...
DEBUG:pycarwings2.pycarwings2:invoking carwings API: https://gdcportalgw.its-mo.com/api_v190426_NE/gdc/InitialApp_v2.php
DEBUG:pycarwings2.pycarwings2:params: {
   "RegionCode": "NCI",
   "custom_sessionid": "",
   "initial_app_str": "9s5rfKVuMrT03RtzajWNcA",
   "lg": "en-US"
}
DEBUG:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): gdcportalgw.its-mo.com:443
DEBUG:requests.packages.urllib3.connectionpool:https://gdcportalgw.its-mo.com:443 "POST /api_v190426_NE/gdc/InitialApp_v2.php HTTP/1.1" 200 None
DEBUG:pycarwings2.pycarwings2:Response HTTP Status Code: 200
DEBUG:pycarwings2.pycarwings2:Response HTTP Response Body: b'{"status":200,"message":"success","baseprm":"88dSp7wWnV3bvv9Z88zEwg"}'
DEBUG:pycarwings2.pycarwings2:invoking carwings API: https://gdcportalgw.its-mo.com/api_v190426_NE/gdc/UserLoginRequest.php
DEBUG:pycarwings2.pycarwings2:params: {
   "Password": "(snip)",
   "RegionCode": "NCI",
   "UserId": "(SNIP)",
   "custom_sessionid": "",
   "initial_app_str": "9s5rfKVuMrT03RtzajWNcA"
}
DEBUG:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): gdcportalgw.its-mo.com:443
DEBUG:requests.packages.urllib3.connectionpool:https://gdcportalgw.its-mo.com:443 "POST /api_v190426_NE/gdc/UserLoginRequest.php HTTP/1.1" 200 None
DEBUG:pycarwings2.pycarwings2:Response HTTP Status Code: 200
DEBUG:pycarwings2.pycarwings2:Response HTTP Response Body: b'{"status":"-2010","message":"INVALID PARAMS","resultKey":""}'
ERROR:pycarwings2.pycarwings2:carwings error INVALID PARAMS: -2010
Traceback (most recent call last):
  File "./get-leaf-info.py", line 61, in <module>
    leaf = s.get_leaf()
  File "/home/fermulator/.local/lib/python3.6/site-packages/pycarwings2/pycarwings2.py", line 212, in get_leaf
    self.connect()
  File "/home/fermulator/.local/lib/python3.6/site-packages/pycarwings2/pycarwings2.py", line 186, in connect
    "Password": encodedPassword,
  File "/home/fermulator/.local/lib/python3.6/site-packages/pycarwings2/pycarwings2.py", line 160, in _request
    raise CarwingsError("INVALID PARAMS")
pycarwings2.pycarwings2.CarwingsError: INVALID PARAMS
$ cat my_config.ini 
[get-leaf-info]
username = (SNIP)
password = (SNIP)
; NNA=USA, NE=Europe, NCI=Canada, NMA=Austrailia, NML=Japan
region = NCI

Open to working through/debugging (just filing the issue report for now). If anyone has guidance happy for it to get a jump start.

It may be worth noting (since I'm not sure if different regions have different account rules):

  • my username is an e-mail address ([email protected])
  • my password has special chars in it (alphanumeric + @, -)

fermulator avatar Feb 09 '20 01:02 fermulator