G-Two / subarulink

A python package for interacting with Subaru STARLINK remote vehicle services.
Apache License 2.0
82 stars 14 forks source link

Cannot get to work on Windows PC. Suspect 2-Factor authentication issue? #68

Closed peter-hardman closed 1 year ago

peter-hardman commented 1 year ago

I have double checked my username and password, but always get an error when I try to connect for the first time with an empty config file. I suspect that the Subaru side is not recognizing the device I am using and so refuses until I go through 2-factor setup.

When I used a browser on the same PC it asked for the 2FA and I was able to then connect in Chrome, but the CLI tool is still failing. I have no idea what information the Subaru site is caching to decide if I am a valid device.

Any suggestions?

2023-01-06 13:57:49,510 - subarulink.connection - ERROR - RequestInfo(url=URL('https://mobileapi.prod.subarucs.com/g2v21/login.json'), method='POST', headers=<CIMultiDictProxy('Host': 'mobileapi.prod.subarucs.com', 'User-Agent': 'Mozilla/5.0 ( 'one exists.


Apache ' 'Tomcat/8.5.58

') 2023-01-06 13:57:49,514 - subarulink - ERROR - Unable to connect: HTTP 404: <ClientResponse(https://mobileapi.prod.subarucs.com/g2v21/login.json) [404 ]> <CIMultiDictProxy('Date': 'Fri, 06 Jan 2023 18:57:49 GMT', 'Content-Type': 'text/html;charset=utf-8', 'Content-Length': '682', 'Connection': 'keep-alive', 'Content-Language': 'en', 'Cache-Control': 'max-age=0, no-cache, no-store, must-revalidate', 'Pra gma': 'no-cache')>

stboch commented 1 year ago

duplicate #60 Please update your SubaruLink version this has already need fixed.

peter-hardman commented 1 year ago

I updated to the latest version. I only had version 0.4.3 because I was using Python 3.8, but I just updated to Python 3.11 and version 0.7.2 of subarulink and I still see the same issues.

peter-hardman commented 1 year ago

Oops did not mean to close this.

stboch commented 1 year ago

The CLI should have support for the 2FA, can you try -v2 to increase the debugging. Also were you using -i for interactive mode?

peter-hardman commented 1 year ago

Was running in interactive mode to generate the config file. Will try -v2 to see what additional info I can get. Also wondering if this could be an issue with a firewall?

From: stboch @.> Sent: Monday, January 9, 2023 9:44 AM To: G-Two/subarulink @.> Cc: Peter @.>; State change @.> Subject: [EXTERNAL] Re: [G-Two/subarulink] Cannot get to work on Windows PC. Suspect 2-Factor authentication issue? (Issue #68)

PLEASE NOTE: Please use caution when opening links and attachments in this message.

The CLI should have support for the 2FA, can you try -v2 to increase the debugging. Also were you using -i for interactive mode?

- Reply to this email directly, view it on GitHubhttps://deu01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FG-Two%2Fsubarulink%2Fissues%2F68%23issuecomment-1375728176&data=05%7C01%7Cpeter.hardman%40evidentscientific.com%7C58333a7fcdaf49d927e808daf24fe926%7Cde05852ab7104511a1c521f394afd842%7C0%7C0%7C638088725119042477%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000%7C%7C%7C&sdata=9IVq1VGqvAyPlC%2Bz2BnYra%2B7YFBe%2Be9ylXvHfiYcffk%3D&reserved=0, or unsubscribehttps://deu01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAQLCOZ7RGBRNASZ6G3IVRDDWRQPZ3ANCNFSM6AAAAAATTLX46M&data=05%7C01%7Cpeter.hardman%40evidentscientific.com%7C58333a7fcdaf49d927e808daf24fe926%7Cde05852ab7104511a1c521f394afd842%7C0%7C0%7C638088725119042477%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000%7C%7C%7C&sdata=RV2Z8DsrZIliwP0iw3eKpCGW92228yONqnl8wH65Qtw%3D&reserved=0. You are receiving this because you modified the open/close state.Message ID: @.**@.>>

peter-hardman commented 1 year ago

User Error :-( Looks like it was somehow still using the old package. Once I cleaned that up I was able to get the 2FA show up in the interactive mode. I have 2 vehicles in my account but something went wrong choosing the one that has starlink

Available Vehicles: [1] Imprezza (XXXXXXXXXXXXXXXX) - 2013 Impreza [2] Outback (XXXXXXXXXXXXXXXX) - 2020 Outback

Select Vehicle> 2 2023-01-09 10:02:50,244 - subarulink - INFO - Fetching data for Outback... Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "C:\Users\peter.hardman\AppData\Local\Programs\Python\Python311\Scripts\subarulink.exe__main__.py", line 7, in last_fetch = self.get_last_fetch_time(vin).timestamp() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ OSError: [Errno 22] Invalid argument Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x0000025D16414190> Unclosed connector connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x0000025D163C7150>, 559959.046)]'] connector: <aiohttp.connector.TCPConnector object at 0x0000025D164141D0>

peter-hardman commented 1 year ago

I modified the config file to add the default_vin key and I am still seeing an error. Looks like the request for the specific info from my vehicle is not being returned and the code is bailing out in the fetch .

2023-01-09 10:53:00,391 - subarulink.controller - DEBUG - Parsing vehicle: XXXXXXXXXXXXX 2023-01-09 10:53:00,391 - subarulink.controller - DEBUG - Parsed recommended tire pressure for XXXXXXXXXXXXXXX: {'FRONT_TIRES': 35, 'REAR_TIRES': 33} 2023-01-09 10:53:00,392 - subarulink.controller - DEBUG - Subaru Remote Services Ready 2023-01-09 10:53:00,392 - subarulink - INFO - Successfully connected 2023-01-09 10:53:00,392 - subarulink - INFO - Fetching data for Outback... Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "C:\Users\peter.hardman\AppData\Local\Programs\Python\Python311\Scripts\subarulink.exe__main__.py", line 7, in File "C:\Users\peter.hardman\AppData\Local\Programs\Python\Python311\Lib\site-packages\subarulink\app\cli.py", line 715, in main LOOP.run_until_complete(cli.single_command(args.command, args.vin, cli.config)) File "C:\Users\peter.hardman\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "C:\Users\peter.hardman\AppData\Local\Programs\Python\Python311\Lib\site-packages\subarulink\app\cli.py", line 530, in single_command if await self._connect(interactive=False, vin=vin): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\peter.hardman\AppData\Local\Programs\Python\Python311\Lib\site-packages\subarulink\app\cli.py", line 400, in _connect await self._vehicle_select(interactive, vin) File "C:\Users\peter.hardman\AppData\Local\Programs\Python\Python311\Lib\site-packages\subarulink\app\cli.py", line 192, in _vehicle_select await self._fetch() File "C:\Users\peter.hardman\AppData\Local\Programs\Python\Python311\Lib\site-packages\subarulink\app\cli.py", line 389, in _fetch await self.ctrl.fetch(self.current_vin, force=True) File "C:\Users\peter.hardman\AppData\Local\Programs\Python\Python311\Lib\site-packages\subarulink\controller.py", line 554, in fetch last_fetch = self.get_last_fetch_time(vin).timestamp() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ OSError: [Errno 22] Invalid argument Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x000001967B3D4650> Unclosed connector connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x000001967B3830E0>, 562979.578)]'] connector: <aiohttp.connector.TCPConnector object at 0x000001967B3D4690>

G-Two commented 1 year ago

I think this is because I initialize the last_fetch datetime object with a timestamp of zero (epoch) which isn't handled well by Windows. I'll try initializing the timestamp to 1980 or something which will probably fix it.

G-Two commented 1 year ago

@peter-hardman please try v0.7.3 and let me know if that fixes the problem for you

peter-hardman commented 1 year ago

Thanks! That fixed the issue for me on Windows.