KarlJorgensen / virgin-media-hub3

Python API and command line interface to the Virgin Media Hub 3 broadband router
GNU General Public License v3.0
77 stars 18 forks source link

HTTPError: 401 Client Error: Unauthorized for url #15

Open pablorodz opened 3 years ago

pablorodz commented 3 years ago

I'm getting the following warning and error:

The only difference I see from Supported Routers is the firmware version.

Steps to reproduce

Result

$ ./hub info
modelname : TG2492LG-85
family : 852
hardware_version : 10
serial_number : AAAP72630959
bootcode_version : 4.2.0.45
firmware_version : 9.1.1912.302
name : Home
current_time_status : TODStatus.RETRIEVED
current_time : 2020-10-23 14:47:56
uptime : 11:38:21.750000
first_install_wizard_completed : True
wan_ip_prov_mode : 1
wan_current_ipaddr_ipv4 : 82.27.120.223
wan_current_ipaddr_ipv6 : None
dns_servers :
+------------+---------------+
| ip_version | ipaddr        |
+------------+---------------+
| IPv4       | 194.168.4.100 |
| IPv4       | 194.168.8.100 |
+------------+---------------+
/home/pablo/virgin-media-hub3/virginmedia.py:126: UserWarning: Got http status 500 - retrying after 1 seconds
  % (resp.status_code, sleep))
Traceback (most recent call last):
  File "./hub", line 611, in <module>
    main()
  File "./hub", line 606, in main
    args.func(hub, args)
  File "/home/pablo/virgin-media-hub3/virginmedia.py", line 231, in __exit__
    self.logout()
  File "/home/pablo/virgin-media-hub3/virginmedia.py", line 209, in logout
    self._get('logout', retry401=0, params=self._nonce)
  File "/home/pablo/virgin-media-hub3/virginmedia.py", line 131, in _get
    resp.raise_for_status()
  File "/home/pablo/.local/lib/python3.7/site-packages/requests/models.py", line 941, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: http://192.168.0.1/logout?_=1603460867528&_n=87128
ProProductionsUK commented 3 years ago

I've also run into this same issue. Seems the people behind this may have given up working on it. So I'm going to dig a little further & see if I can figure it out. I can only guess that as the equipment this code is built for is owned by the ISP that they may have added something within the firmware to block external scripts/code from communication.

I'll add info as/when I can figure it out.

beardedfool commented 2 years ago

Just seeing if either of you got anywhere with this please?

pablorodz commented 2 years ago

I haven't tried anything, sorry.

developer-iname commented 2 years ago

Same Error. If someone with any sort of networking experience can help debug this, would be greatly appreciated.

AzinKhan commented 1 year ago

FWIW, I'm seeing the same error printed out after each command but the commands themselves actually seem to work 🤔. I was able to update my port forwarding rules successfully.

Looking a bit more closely at the traceback, the error occurs when attempting to log out as part of exiting the Hub context manager. As far as I can tell, what happens is:

It seems to me, since attempting to log out induces a 500 response from the router, that there might be a problem at the router's end?

For now, I'm happy to ignore the errors as it doesn't appear to be causing a problem 🤷 .