trocotronic/weconnect

Cannot get data after updates

Closed this issue · 6 comments

After the changes in ce5a2cd, I can no longer connect. The version before still works fine for me, but when I use anything more recent, I get a name lookup failure:

HTTPSConnectionPool(host='fal-1a.prd.ece.vwg-connect.com', port=443): Max retries exceeded with url: /fs-car/vehicleMgmt/vehicledata/v2/VW/DE/vehicles/WVWZZZAUZK8907162 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fa7e67c4c40>: Failed to establish a new connection: [Errno -2] Name or service not known'))

After investigating this some more, it seems like the r['homeRegion']['baseUri']['content'] received from the server is set to https://mal-1a.prd.ece.vwg-connect.com/api, which is used to form the mal3 URL by replacing mal with fal.

If I hardcode the fal3 URL to use BASE_URL instead, the connection works better. But then the next problem is that the VSR parsing of the updated codes fails, while the old codes work. And also sometimes the T&C handling code seems to cause some issues. Sometimes there is no "carnet://" in the latest redirect URL despite that everything looks good. By commenting out the attempt to parse T&C, the communication proceeds again.

Is it possible that they reverted some changes on the server side, causing the latest updates here to fail?

That's not the way it works. r['homeRegion']['baseUri']['content'] should return mal3 uri, not mal1. In my region, it returns mal-3a.prd.eu.dp.vwg-connect.com. If it returns mal1, it is a very rare behaviour. To me it is very hard to debug, as I am in another region, which it pretty works.

Try to add
self.__identities['fal3'] = 'https://WHATEVER.YOU.THINK.IT.IS.CORRECT/fs-car'
at the end of __get_homeregion to override fal3 entry point.

Old code works becauses it uses an old backend, with outdated car information. Newer backends use mal1, mal3 and fal3 entry points. mal1 is the entry point of your profile, whilst fal3 is the entry point of you VIN.

T&C is a nightmare because it appears randomly, when they change T&C, and the format changes at every trial. If it stucks with T&C, try to accept them through the app once. Which is the error raised when no carnet:// is found?

I don't know which the different regions are, but I am in the EU region as well, and the official app communicates with the same fal3 URL you mention. However, I constantly get mal-1a.prd.ece.vwg-connect.com as r['homeRegion']['baseUri']['content'].

If I manually change to fal-3a.prd.eu.dp.vwg-connect.com, I get other errors:
[27/06/2021 09:06:36] [INFO] Response with code: 500 [27/06/2021 09:06:36] [DEBUG] Headers: {'X-FS-Tracking-ID': '5c...redacted', 'X-FS-Error-Code': 'GW500', 'Content-Type': 'application/vnd.vwg.mbb.genericError_v1_0_2+json;charset=UTF-8', 'Content-Length': '185', 'Date': 'Sun, 27 Jun 2021 07:06:36 GMT', 'Connection': 'close', 'Server': 'www'} [27/06/2021 09:06:36] [DEBUG] History: [] [27/06/2021 09:06:36] [DEBUG] Response error in JSON format [27/06/2021 09:06:36] [CRITICAL] Raising error msg: Error 500: [mbbc.vehiclemanagement.promoterv1.lookup.error] Error while retrieving data for the isConnect flag. Got the following error FAULT_INTERNAL_ERROR Traceback (most recent call last): File "example.py", line 36, in <module> details = vwc.get_vehicle_data(vin) File "/home/matli/devel/weconnect/weconnect/NativeAPI.py", line 565, in get_vehicle_data r = self.__command('/vehicleMgmt/vehicledata/v2/VW/DE/vehicles/'+vin, dashboard=self.__get_fal_url(vin), scope=self.__oauth['sc2:fal'], accept=__accept) File "/home/matli/devel/weconnect/weconnect/NativeAPI.py", line 260, in __command r = self.__get_url(dashboard+command, json=post, post=data, headers=headers) File "/home/matli/devel/weconnect/weconnect/NativeAPI.py", line 220, in __get_url raise UrlError(r.status_code, msg, r) NativeAPI.UrlError: Error 500: [mbbc.vehiclemanagement.promoterv1.lookup.error] Error while retrieving data for the isConnect flag. Got the following error FAULT_INTERNAL_ERROR

Regarding T&C, I have accepted the T&C manually, which made the old version work a while ago. However, when running now, whenever the __force_login is called, I get the following:
Traceback (most recent call last): File "example.py", line 15, in <module> vwc.login() File "/home/matli/devel/weconnect/weconnect/NativeAPI.py", line 366, in login return self.__force_login() File "/home/matli/devel/weconnect/weconnect/NativeAPI.py", line 437, in __force_login soup = BeautifulSoup(r.text, 'html.parser') AttributeError: 'CarNetResponse' object has no attribute 'text'

That's probably because the r.history[-1].url is just a 302 message, with no body and an URL of https://identity.vwgroup.io/oidc/v1/oauth/client/callback/success?user_id=<redacted>
If I just comment out the block starting with if ('carnet://' not in r.history[-1].url):, the login proceeds without problems

Add this add the end of example.py and paste the response (hide vin and any sensitive information):

import json
r = vwc.get_roles_rights(vin)
print(json.dumps(r))

Regarding T&C, please use latest version as it fixed it.

Yes, T&C seems to work with the latest version. And this version now connects, but the VSR parsing still fails. I get a huge amount of warnings from parse_vsr, e.g.
[27/06/2021 21:58:56] [WARNING] [parse_vsr] item 0x030101FFFF, field 0x0301010001 not found [27/06/2021 21:58:56] [WARNING] [parse_vsr] {'id': '0x0301010001', 'tsCarSentUtc': '2021-06-27T13:10:34Z', 'tsCarSent': '2021-06-27T13:10:21', 'tsCarCaptured': '2021-06-27T13:10:21', 'tsTssReceivedUtc': '2021-06-27T13:10:39Z', 'milCarCaptured': 35726, 'milCarSent': 35726, 'value': '2', 'textId': 'status_parking_light_off'}
So the return of parse_vsr only contains {'utc_time': 'echo', 'distance_covered': '35726'}

See the attached file for the response from the get_roles_rights.

Does 3eb9ac1 fix it? Do not forget to move your credentials to credentials.py and use updated example.py

Yes, thanks! Now it seems to work fine!