AndroidSec AndroidSec - 1 year ago 149
Android Question

Android WebView - does it support digest authentication?

I think the title is self explanatory. I can't find any resources or references that mention that digest authentication is supported in WebViews.

A couple of caveats:

  • I'm not talking about basic authentication where the authorisation header is sent with base64 encoding.

  • I'm only talking about WebViews embedded in an application, not simple http requests where apache http client can be used for example.

Answer Source

You can set one WebViewClient in your WebView and override below method in your WebViewClient, see below code..

private class ExWebChromeClient extends WebViewClient {
    public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm) {
        super.onReceivedHttpAuthRequest(view, handler, host, realm);    //To change body of overridden methods use File | Settings | File Templates.

webView.setWebViewClient(new ExWebChromeClient());//set your Extended WebViewClient here

Here you can show one auth dialog..See showHttpAuthentication method from Android native Browser app here, here one http auth dialog is shown and handled properly inside WebView

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download