flobz / psa_car_controller

Control psa car with connected_car v4 API.
GNU General Public License v3.0
429 stars 226 forks source link

SMS and PIN after every restart #63

Closed CWfFO closed 3 years ago

CWfFO commented 3 years ago

Hi i am using since today the up2date Version. After every restart i have now to enter a new SMS code and my PIN. Is there any way to avoid this?

  1. what command did you use: python3 server.py -f test.json -c charge_config.json -r -l 192.168.99.13
  2. when the bug append ? after every testart
  3. Does it persist after restarting the program? yes

    OS: Raspian Android app Version [e.g. 26.0] 1.27.1 Brand and model of car: Opel Application version (commit number, branch): master

KR Christian

flobz commented 3 years ago

Hi, This isn't normal, delete otp.bin and retry.

CWfFO commented 3 years ago

No sorry. Still the same behavior

flobz commented 3 years ago

Do you have any error in the log?

schombat commented 3 years ago

Hi all, same behavior here. Since the last update on the application keeps asking for SMS code and PIN. Used to work on Mar 28th. I suppose problem is somehow related to "Merge pull request" #55.
My first thought was that the problem could be caused by a temporary block of my account (e.g. rate limit exceeded) after I did several retries of starting the server to fix Bug #59 cannot start server - Opel Corsa-e by myself before the fix was published, but the problem still persists after >48 hours.

Command: python3 server.py -f test.json -c charge_config1.json -d 9 OS: BOTH Mac OS w/ Python 3.9.2 AND Raspian w/ Python 3.7.3 Android app version: BOTH MyOPEL 1.29.0 AND MyOPEL 1.28.2 Application version: master Brand and model of car: Opel Corsa-e (without onboard navigation system)

Tried deleting otp.bin, cars.json, charge_config1.json and test.json and new app_decoder runs, but problem persists.

Log shows error 2021-04-02 20:54:30,577 :: ERROR :: remote_refresh_token isn't defined

Problem seems to be related to the Finalize Action ActionFinalize which returns an <err>NOK:FORBIDDEN</err>. ActionSetupright before that returns <err>OK</err>

mitmproxy shows the following flows:

https://idpcvs.opel.com/am/oauth2/access_token  POST    400 167b    135ms
https://idpcvs.opel.com/am/oauth2/access_token  POST    200 973b    173ms
https://api.groupe-psa.com/connectedcar/v4/user/vehicles?client_id=01234567-12ab-1234-1234-1a012ab1a12a GET 200 2.6kb   514ms
https://idpcvs.opel.com/am/oauth2/access_token  POST    200 956b    175ms
https://api.groupe-psa.com/applications/cvs/v4/mobile/smsCode?client_id=01234567-12ab-1234-1234-1a012ab1a12a    POST    202 31b 631ms
https://otp.mpsa.com/iwws/MAC?action=ActionSetup&mode=activate&id=&lastsync=0&version=Generator-1.0%2F0.2.11&macid=[...]&code=[SMS] GET 200 754b    139ms
https://otp.mpsa.com/iwws/MAC?action=ActionFinalize&mode=activate&id=&lastsync=0&version=Generator-1.0%2F0.2.11&lang=fr&ack=&macid=macid=[...]&serial=[...]&code=[SMS]&Kma=[...]&pin=[...]&name=Android+SDK+built+for+x86_64+%2F+UNKNOWN&R0=[...]&R1=[...]&R2=[...] `GET`   200 182b    149ms
https://api.groupe-psa.com/connectedcar/v4/virtualkey/remoteaccess/token?client_id=01234567-12ab-1234-1234-1a012ab1a12a POST    400 125b    218ms
https://otp.mpsa.com/iwws/MAC?action=ActionSetup&mode=otp&id=&lastsync=0&version=Generator-1.0%2F0.2.11&macid=[...] GET 200 94b 59ms

Step https://otp.mpsa.com/iwws/MAC?action=ActionSetup&mode=activate&id=&lastsync=0&version=Generator-1.0%2F0.2.11&macid=[...]&code=[SMS] returns OK:

<?xml version="1.0" encoding="Iso-8859-1"?>
<ActionSetup>
  <Kiw>[...]</Kiw>
  <Kfact>[...]</Kfact>
  <pinmode>1</pinmode>
  <newversion>2.0.0</newversion>
  <newversionurl>http://m.inwebo.com/</newversionurl>
  <err>OK</err>
</ActionSetup>

But step https://otp.mpsa.com/iwws/MAC?action=ActionFinalize&mode=activate&... returns <err>NOK:FORBIDDEN</err>:

<?xml version="1.0" encoding="Iso-8859-1"?>
<ActionFinalize>
  <newversion>2.0.0</newversion>
  <newversionurl>http://m.inwebo.com/</newversionurl>
  <err>NOK:FORBIDDEN</err>
</ActionFinalize>

and subsequently step https://otp.mpsa.com/iwws/MAC&action=ActionSetup&mode=otp&id=&lastsync=0&version=Generator-1.0%2F0.2.11&macid=[...] returns <err>NOK:NODEVICE</err>

<?xml version="1.0" encoding="Iso-8859-1"?>
<ActionSetup>
  <err>NOK:NODEVICE</err>
</ActionSetup>
flobz commented 3 years ago

Ok, on a fresh myopel install on a smartphone, connect and test remote control. It should say that you need to reset your account or something like that.

CWfFO commented 3 years ago

Hi, my account isn't blocked. Here is a error which i see : 2021-04-03 08:45:26,234 :: ERROR :: remote_refresh_token isn't defined What is the code you just received by SMS ?

flobz commented 3 years ago

Have you followed my instructions? It should print an error like this now "Error during activation....."

schombat commented 3 years ago

Ok, on a fresh myopel install on a smartphone, connect and test remote control. It should say that you need to reset your account or something like that.

Thanks for the quick response! I followed your instructions (fresh app install), and the app actually asked for a reset of the app PIN. After doing so, the registration worked again - thanks for the hint. But: the reported behavior (SMS code and PIN requested after every restart) is still present. Log shows error 2021-04-03 10:03:29,207 :: ERROR :: remote_refresh_token isn't defined, then SMS/PIN are requested. But after that another error is logged: 2021-04-03 10:03:59,580 :: ERROR :: can't refresh_remote_token: {'error': 'invalid_grant', 'error_description': 'grant is invalid'}

dreimer1986 commented 3 years ago

I had a similar one in the past. I have zero clue if things are still behaving that way, but... rename test.json to config.json and modify the command line accordingly.

xammmue commented 3 years ago

I had the same issue after pulling, ommitting -f test.json from the command helped.

Problem occurrs as the defined config name from the command is only used for loading but not for saving. PR #64 should fix that behavior

CWfFO commented 3 years ago

I changed to the newest files and now i am in a loop: 2021-04-04 10:33:22,610 :: ERROR :: Error during activation: {'newversion': '2.0.0', 'newversionurl': 'http://m.inwebo.com/', 'err': 'NOK:FORBIDDEN'} And then it sends a new SMS and then the same error again. After this i get: otp.Otp.ConfigException: Can't get otp code

CWfFO commented 3 years ago

It seems to work now :) Next time i just follow your infos flobz. Sorry. I did a fresh install of the opel app on a second phone. He asked to reset my PIN. I did this and now it seems to work. I keep a eye on it. Do you have any idea why this happend?

flobz commented 3 years ago

Yes it happens after 20 sms received.