Python Forum
authentication required error with urlopen
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
authentication required error with urlopen
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('') as story:
    story_words = []
    for line in story:
        line_words = line.decode('utf-8').split()
        for word in line_words:
Traceback (most recent call last): File "", line 3, in <module> with urlopen('') as story: File "C:\HOMEWARE\Anaconda3-Windows-x86_64\lib\urllib\", line 223, in urlopen return, data, timeout) File "C:\HOMEWARE\Anaconda3-Windows-x86_64\lib\urllib\", line 532, in open response = meth(req, response) File "C:\HOMEWARE\Anaconda3-Windows-x86_64\lib\urllib\", line 642, in http_resp File "C:\HOMEWARE\Anaconda3-Windows-x86_64\lib\urllib\", line 532, in open response = meth(req, response) File "C:\HOMEWARE\Anaconda3-Windows-x86_64\lib\urllib\", line 642, in http_response 'http', request, response, code, msg, hdrs) File "C:\HOMEWARE\Anaconda3-Windows-x86_64\lib\urllib\", line 570, in error return self._call_chain(*args) File "C:\HOMEWARE\Anaconda3-Windows-x86_64\lib\urllib\", line 504, in _call_chain result = func(*args) File "C:\HOMEWARE\Anaconda3-Windows-x86_64\lib\urllib\", line 650, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp)urllib.error.HTTPError: HTTP Error 407: authenticationrequired
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.
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.

Possibly Related Threads…
Thread Author Replies Views Last Post
  error : "Microsoft Visual C++ 14.0 is required. " Even its installed Barak 4 1,510 Oct-13-2021, 10:39 PM
Last Post: Underscore
  SharePoint Online/365 authentication using .cer file mart79 0 626 Nov-08-2020, 03:31 PM
Last Post: mart79
  how to solve "a bytes-like object is required, not 'str'" error maiya 2 1,185 Jul-28-2020, 07:03 PM
Last Post: bowlofred
  Authentication error when accessing Microsoft SharePoint klllmmm 3 3,701 Jun-10-2020, 07:46 AM
Last Post: nuffink
  unable to generate authentication key lokamaba 0 795 May-14-2020, 12:33 PM
Last Post: lokamaba
  need some help to do Vault authentication using python dspy9 0 619 Apr-15-2020, 07:22 PM
Last Post: dspy9
  user authentication in python saurabhc 1 1,068 Sep-15-2019, 11:59 AM
Last Post: jefsummers
  Type error: dump() missing 1 required positional argument: fp jaycuff13 2 12,594 Jul-13-2019, 10:21 AM
Last Post: jaycuff13
  missing 1 required positional argument error nikos 3 4,822 Feb-28-2019, 12:53 PM
Last Post: nikos
  Error "an integer is required" in getpass.getuser(). Nirelg 5 3,645 Mar-20-2017, 04:19 AM
Last Post: nilamo

Forum Jump:

User Panel Messages

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