How do I setup username and password for the http proxy on Android webview (chromium)?

854 views
Skip to first unread message

Gao Huang

unread,
Sep 28, 2018, 2:44:21 PM9/28/18
to Chromium-dev

Dear guys:

       We have a requirement to use http proxy on Android webview, and we found that the interface of the system only accept server and port without username and password.

       Do you have any tips how I can use http proxy with username and password on Android webview (Chromium)?

       Following are the codes we use:

           System.setProperty("http.proxyHoxyHost", host);

           System.setProperty("http.proxyPoxyPort", port + "");

           System.setProperty("https.proxyHoxyHost", host);

           System.setProperty("https.proxyPoxyPort", port + "");

       Thanks a lot!

 

Best Regards

Huang Gao

Torne (Richard Coles)

unread,
Sep 28, 2018, 3:27:01 PM9/28/18
to huan...@gmail.com, Laís Minchillo, Chromium-dev
This is not a supported API. We're introducing a supported API to set the proxy settings but it's not yet available. I don't know if it supports authentication, though; Laís, are we including that?
 

       Thanks a lot!

 

Best Regards

Huang Gao

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/353bfdc4-4cd3-4f68-8e39-c1ad6c946a2a%40chromium.org.

Gao Huang

unread,
Sep 28, 2018, 8:48:08 PM9/28/18
to Chromium-dev, huan...@gmail.com, laismi...@google.com

Hello, Richard:

       Thank you very much for your reply!

       So before the official solution is released on Android, do I have any bypass method to do this work, such as use Java reflection or native hook to setup the username and password of https proxy in Chromium?


Best Regards

Huang Gao

Yahali Sherman

unread,
Oct 10, 2023, 2:35:13 PM10/10/23
to Chromium-dev, Torne (Richard Coles), Chromium-dev, huan...@gmail.com, Laís Minchillo
Hey, following up on this question When using http proxy:
System.setProperty("http.proxyHost", host); //host = "http://proxy.my.com
System.setProperty("http.proxyPort", port + "");

I'm able to use override onReceivedHttpAuthRequest (see below) to respond to 407 response from the proxy and set username & password.

.setWebViewClient(
object : SecureWebViewClient() {
override fun onReceivedHttpAuthRequest(
view: WebView,
handler: HttpAuthHandler,
host: String,
realm: String
) {
handler.proceed(username, password)
}
})

But when trying the same with host = "https://proxy.my.com" it will not call onReceivedHttpAuthRequest and I'm getting net::ERR_PROXY_AUTH_UNSUPPORTED

Any idea how to allow this with a proxy that is HTTPS or better - how to pass the credentials in advance?

thanks!
Yahali

Yahali Sherman

unread,
Oct 10, 2023, 2:38:06 PM10/10/23
to Chromium-dev, Torne (Richard Coles), Chromium-dev, huan...@gmail.com, Laís Minchillo, Yahali Sherman
Following up on this question with a twist.
I was able to use the below code to set the proxy host & port and with http proxy (e.g. host="http://proxy.mydomain.com"), onReceivedHttpAuthRequest will be called when the proxy returnd 407 challenge.
However when the proxy is https (e.g. host="https://proxy.mydomain.com") onReceivedHttpAuthRequest is not called and I immediately get net::ERR_PROXY_AUTH_UNSUPPORTED.
Any idea how I can either pass username|password in advance? (setting system properties http.proxyUser, http.proxyPassword is not helping, nor overriding the java.net.Authenticator default). 
or bypass the error 

thanks!
Yahali

System.setProperty("http.proxyHost", host);
System.setProperty("http.proxyPort", port + "");

someWebView.setWebViewClient(

object : SecureWebViewClient() {
override fun onReceivedHttpAuthRequest(
view: WebView,
handler: HttpAuthHandler,
host: String,
realm: String
) {
handler.proceed(username, password)
}
})
On Friday, September 28, 2018 at 10:27:01 PM UTC+3 Torne (Richard Coles) wrote:

Zubair Khakwani

unread,
Oct 17, 2023, 2:41:38 PM10/17/23
to Chromium-dev, Yahali Sherman, Torne (Richard Coles), Chromium-dev, huan...@gmail.com, Laís Minchillo
i don't know if i am posting this question at the right place?

,I am trying to launch Chrome from the command line and passing --proxy-server=host:port and it works but I have to enter credentials in popup window, so passing credentials in this flag is going to be supported any soon?
Reply all
Reply to author
Forward
0 new messages