Python Forum
authentication required error with urlopen
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
authentication required error with urlopen
#1
Hello Everyone,
I'm trying following code, but ending up Authentication Required Error. I'm able to browse the website from browser without any credentials, but not through python script. How can I mitigate this error? Any Help please?

from urllib.request import urlopen
with urlopen('http://sixty-north.com/c/t.txt') as story:
    story_words = []
    for line in story:
        line_words = line.decode('utf-8').split()
        for word in line_words:
            story_words.append(word)
print(story_words)
Error:
Traceback (most recent call last): File "f_test_area.py", line 3, in <module> with urlopen('http://sixty-north.com/c/t.txt') as story: File "C:\HOMEWARE\Anaconda3-Windows-x86_64\lib\urllib\request.py", line 223, in urlopen return opener.open(url, data, timeout) File "C:\HOMEWARE\Anaconda3-Windows-x86_64\lib\urllib\request.py", line 532, in open response = meth(req, response) File "C:\HOMEWARE\Anaconda3-Windows-x86_64\lib\urllib\request.py", line 642, in http_resp File "C:\HOMEWARE\Anaconda3-Windows-x86_64\lib\urllib\request.py", line 532, in open response = meth(req, response) File "C:\HOMEWARE\Anaconda3-Windows-x86_64\lib\urllib\request.py", line 642, in http_response 'http', request, response, code, msg, hdrs) File "C:\HOMEWARE\Anaconda3-Windows-x86_64\lib\urllib\request.py", line 570, in error return self._call_chain(*args) File "C:\HOMEWARE\Anaconda3-Windows-x86_64\lib\urllib\request.py", line 504, in _call_chain result = func(*args) File "C:\HOMEWARE\Anaconda3-Windows-x86_64\lib\urllib\request.py", line 650, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp)urllib.error.HTTPError: HTTP Error 407: authenticationrequired
Reply
#2
It seems you connect to the Internet via a proxy server. Your browser is set to work with the proxy but your program is not.
Reply
#3
Yes True, we use proxy like every company does.
I'm able to open the URL via any web browser without asking for credentials but not through the Python code.
Is there any way to get this working by passing my default credentials explicitly?

Sorry, i was out of connection for a week hence delay in response.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  REST API x.509 authentication crossover 1 2,441 Feb-15-2022, 12:21 AM
Last Post: snippsat
  error : "Microsoft Visual C++ 14.0 is required. " Even its installed Barak 4 3,998 Oct-13-2021, 10:39 PM
Last Post: Underscore
  how to solve "a bytes-like object is required, not 'str'" error maiya 2 3,783 Jul-28-2020, 07:03 PM
Last Post: bowlofred
  Authentication error when accessing Microsoft SharePoint klllmmm 3 10,299 Jun-10-2020, 07:46 AM
Last Post: nuffink
  Type error: dump() missing 1 required positional argument: fp jaycuff13 2 21,880 Jul-13-2019, 10:21 AM
Last Post: jaycuff13
  missing 1 required positional argument error nikos 3 7,468 Feb-28-2019, 12:53 PM
Last Post: nikos
  Error "an integer is required" in getpass.getuser(). Nirelg 5 5,443 Mar-20-2017, 04:19 AM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020