Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
987 views
in Technique[技术] by (71.8m points)

session - Invalid auth error when making requests to HTTPS endpoints

I am trying to make requests to https endpoints with proxies, but I keep getting a 407 error. When I try the same request on an http endpoint, it works without any errors. I'm not sure what I'm doing wrong.

curl -x ip:port-U user:pass https://api.ipify.org/?format=json

My curl request above works fine meaning my proxy is functional.

class Driver:
    def __init__(self, proxy):
        self.proxy = proxy
        self.ses = requests.Session()
        self.ses.proxies = {'https':'https://user:pass@ip:port'}

        response = self.ses.get('https://api.ipify.org/?format=json')
        print(response.text)

Error:

requests.exceptions.ProxyError: HTTPSConnectionPool(host='api.ipify.org', port=443): Max retries exceeded with url: /?format=json (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Invalid Auth')))
question from:https://stackoverflow.com/questions/65867749/invalid-auth-error-when-making-requests-to-https-endpoints

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...