Sending Proxy Authentication requests with Geckovew on Android

479 Views Asked by At

I am building a proof of concept browser using Geckoview on Android. As part of the requirement I need to be able to configure it to authenticate with a proxy server. I have tried various config options but cannot seem to get a dialog to popup with a proxy auth request or send stored credentials when it receives a 407 from the proxy server. The requests hit the proxy with no auth information and the server responds with a 407.

private fun setupGeckoView() {
    PrefsHelper.setPref("network.proxy.type",1,true)
    PrefsHelper.setPref("network.proxy.http","myproxy.domain.com",true)
    PrefsHelper.setPref("network.proxy.port",3119,true);
    PrefsHelper.setPref("network.proxy.ssl","myproxy.domain.com",true)
    PrefsHelper.setPref("network.proxy.share_proxy_settings", true,true)
    PrefsHelper.setPref("network.proxy.ssl_port",3119,true)
    PrefsHelper.setPref("network.proxy.username","test",true)
    PrefsHelper.setPref("network.proxy.password","testpass",true)
    geckoView = findViewById(R.id.geckoview)

    val runtime = GeckoRuntime.create(this)

    geckoSession.open(runtime)
    geckoView.setSession(geckoSession)
    geckoSession.loadUri(INITIAL_URL)
    urlEditText.setText(INITIAL_URL)

    var customUserAgent = "My UserAgent"
    geckoSession.settings.userAgentOverride = customUserAgent
    geckoSession.progressDelegate = createProgressDelegate()
    geckoSession.settings.useTrackingProtection = true
    geckoSession.contentBlockingDelegate = createBlockingDelegate()
    setupTrackersCounter()
}

I do see the config options set when I do about:config in the emulator and have experimented with settings such as network.automatic-ntlm-auth.allow_proxies (true,false). Can somebody advise on the minimum settings required to setup and http(s) proxy in geckoview.

0

There are 0 best solutions below