AshMartian / carwings

Javascript library for the Nissan Leaf Carwings JSON API
MIT License
0 stars 2 forks source link

Failed login - Status -2010, INVALID PARAMS #4

Open loftux opened 7 years ago

loftux commented 7 years ago

Filing this error here, since to my knowledge it fails in this library, not in the homebridge_carwings.

Login does not work, and if fails with error: Oct 8 11:27:55 raspberrypi homebridge[13344]: _currentUrl: 'https://gdcportalgw.its-mo.com' }, Oct 8 11:27:55 raspberrypi homebridge[13344]: data: { status: '-2010', message: 'INVALID PARAMS' } } Oct 8 11:27:55 raspberrypi homebridge[13344]: Error . More detail log attached carwings_error.txt

I have an older carwings account (3+ years), and in some apps such iOS EVA app I can only login with the user name (not with email). On Nissan web it works with either, also works with both in Nissan EV app. I've tried both user name and email, and with a combination of clear text password and base64 encoded in the config. Versions used is the latest of homebridge_carwings and this carwings library (to the best of my understanding).

I will contact Nissan support to see if it is possible to convert my Carwings account to an email only account.

Thanks!

loftux commented 7 years ago

Further debugging: This is actually the response when password is invalid. I could run this project with the sample/test code in the end, and get the login to work with let session = await loginSession('**', '***'); The code for

data = await api('UserLoginRequest', {
  initial_app_strings,
  UserId: '****',
  Password: blowpassword(key, '*****'),
  RegionCode
});

Needed to have the location for key and password swapped in blowpassword. Also concluded for upstream homebridge_carwings that login works with when password is properly base64 encoded, but not plain text password.

But I now get another error

🍃 api UserLoginRequest 👍
TypeError: Cannot read property 'vehicleInfo' of undefined

I'll continue looking.

loftux commented 7 years ago

Turns out the VehicleInfoLIst isn't available, maybe it's only when you have more than one. Changing the getsessionid and getvin to handle both situations makes it work. Still get errors when running homebridge-carwings, but it is improving.

function getsessionid(profile) {
  if (profile && profile.vehicleInfo[0]) {
    return profile.vehicleInfo[0].custom_sessionid;
  }
  else if (profile && profile.VehicleInfoList && profile.VehicleInfoList.vehicleInfo[0]) {
    return profile.VehicleInfoList.vehicleInfo[0].custom_sessionid;

  } else {
    return null;
  }
}

function getvin(profile) {
  if (profile && profile.vehicleInfo[0]) {
    return profile.vehicleInfo[0].vin;
  }
  else if (profile && profile.VehicleInfoList && profile.VehicleInfoList.vehicleInfo[0]) {
    return profile.VehicleInfoList.vehicleInfo[0].vin;

  } else {
    return null;
  }
}