jhy / jsoup

jsoup: the Java HTML parser, built for HTML editing, cleaning, scraping, and XSS safety.
https://jsoup.org
MIT License
10.95k stars 2.2k forks source link

Jsoup Proxy Authentication Fails: Auth Callback Not Triggered on macOS #2233

Open capmorganbih opened 1 hour ago

capmorganbih commented 1 hour ago

I can’t use a per-request proxy with Jsoup.

Connection s = Jsoup.newSession()
                .proxy("connect.net", 8080)
                .auth(auth -> {
                    if (auth.isServer()) { 
                        Validate.isTrue(auth.url().getHost().equals("example.com"));
                        return auth.credentials("username", "password");
                    } else { // auth.isProxy()
                        return auth.credentials("proxyUsername", "proxyPassword");
                    }
                });

s.newRequest("https://example.com/adminzone/").execute();

This code fails with a 407 Proxy Authentication Required, even though I’m using valid credentials. The key issue is that the auth callback does not get triggered at all

I’m running this on macOS

capmorganbih commented 1 hour ago

@jhy could you please clarify what am I doing wrong?