How to handle windows authentication in Android

March 10, 2014 by Anuraj

Android Miscellaneous

If you are developing enterprise applications you may need to handle windows authentication from mobile devices. Windows authentication (formerly named NTLM, and also referred to as Windows NT Challenge/Response authentication) is a secure form of authentication because the user name and password are hashed before being sent across the network. Here is the snippet which helps to handle windows authentication in Android.

webView = (WebView) findViewById(R.id.webView1);
webView.setWebViewClient(new WebViewClient() {
	@Override
	public void onReceivedHttpAuthRequest(WebView view,
			HttpAuthHandler handler, String host, String realm) {
		handler.proceed("DOMAIN\\username", "password");
	}

});

webView.loadUrl("URL");

Happy Programming :)

Copyright © 2024 Anuraj. Blog content licensed under the Creative Commons CC BY 2.5 | Unless otherwise stated or granted, code samples licensed under the MIT license. This is a personal blog. The opinions expressed here represent my own and not those of my employer. Powered by Jekyll. Hosted with ❤ by GitHub