urllib3.ProxyManager is giving authentication error
Asked Answered
T

1

1

I am trying send a https request using urllib3.ProxyManager. My code looks something like this

default_headers = urllib3.util.make_headers(proxy_basic_auth='user:passwd')
http = urllib3.ProxyManager(proxyUrl, headers=default_headers, ca_certs=certifi.where())
http.request('GET', url)

I am getting below error -

MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='clinicaltrials.gov', port=443): Max retries exceeded with url: /ct2/results?term=Lilly&displayxml=true&count=5000 (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required')))

Thanks, Yatrik

Tran answered 27/9, 2019 at 9:21 Comment(1)
Did you try this solution? https://mcmap.net/q/673338/-python-3-urllib-http-error-407-proxy-authentication-requiredKellar
A
2

I think you need to set proxy_headers, not headers in ProxyManager:

default_headers = urllib3.util.make_headers(proxy_basic_auth='user:passwd')
http = urllib3.ProxyManager(proxyUrl, proxy_headers=default_headers, ca_certs=certifi.where())
http.request('GET', url)

See urllib3.poolmanager.ProxyManager in the docs: https://urllib3.readthedocs.io/en/latest/reference/

Allegedly answered 10/1, 2020 at 17:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.