Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTPError: 401 Client Error: Unauthorized for url #15

Open
pablorodz opened this issue Oct 23, 2020 · 5 comments · May be fixed by #18
Open

HTTPError: 401 Client Error: Unauthorized for url #15

pablorodz opened this issue Oct 23, 2020 · 5 comments · May be fixed by #18

Comments

@pablorodz
Copy link

I'm getting the following warning and error:

  • UserWarning: Got http status 500
  • HTTPError: 401 Client Error: Unauthorized for url

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

Steps to reproduce

  • clone repo
  • install requirements.txt
  • run hub info

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
Copy link

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
Copy link

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

@pablorodz
Copy link
Author

I haven't tried anything, sorry.

@developer-iname
Copy link

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

@AzinKhan
Copy link

AzinKhan commented Nov 9, 2022

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:

  • Hub tries to log out and gets a 500 response from the router.
  • The log out code clears the credentials from the Hub instance. Clearing the credentials occurs in a finally block and so always runs.
  • Since it's configured to retry after 500s, it retries, but this time it has no credentials and hits the 401.

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 🤷 .

@jorrit jorrit linked a pull request Jan 7, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants