Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8413051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:50:15+00:00 2026-06-10T00:50:15+00:00

I have made two attempts in trying to access a website with authentication, and

  • 0

I have made two attempts in trying to access a website with authentication, and I am not sure what is wrong with my attempts. I will list each one. Has anyone tried this and gotten it to work?

This should not be difficult for Java Android programmers to understand, nor should it matter that I am using monodroid EDIT (It DOES matter, because I have a Java implementation below that works just fine)END EDIT.

I am trying to gain access to an SSRS RDL through the WebView and I need to plug in some generic credentials.

ACTIVITY:

    public static string username = "...";
    public static string password = "...";
    public static string website  = "http://10.0.0.5/Reports";

    private WebView webView;

    private void setupWebView(int attempt)
    {
        webView.Settings.JavaScriptEnabled = true;
        webView.Settings.BlockNetworkLoads = false;

        switch (attempt)
        {
            case 1:
                {
                    webView.SetHttpAuthUsernamePassword(website, "", username, password);                                              
                }break;
            case 2:
                {
                    webView.SetWebViewClient(new AuthenticationClient(this));                        
                }break;
        }
        webView.LoadUrl(website);
    }

    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        webView = new WebView(this);

        setupWebView(1);//1 or 2 depending on what I am testing

        // Set our view from the "main" layout resource
        SetContentView(webView);           
    }
}

AuthenticationClient:

    //DECLARED IN ANOTHER FILE
    [Android.Runtime.Register("android/webkit/WebViewClient", DoNotGenerateAcw = true)]
    public class AuthenticationClient:WebViewClient
    {
        private Context _context;

        public AuthenticationClient(Context context)
        {
            _context = context;
        }

        public override void OnReceivedError(WebView view, ClientError errorCode, string description, string failingUrl)
        {
            Toast.MakeText(_context, "OnReceivedError: " + errorCode, ToastLength.Long);
            //base.OnReceivedError(view, errorCode, description, failingUrl);
        }

        public override void OnPageStarted(WebView view, string url, Android.Graphics.Bitmap favicon)
        {
            Toast.MakeText(_context, "OnPageStarted: " + url, ToastLength.Long);
            //base.OnPageStarted(view, url, favicon);
        }

        public override bool ShouldOverrideUrlLoading(WebView view, string url)
        {
            Toast.MakeText(_context, "ShouldOverrideUrlLoading: " + url, ToastLength.Long);
            view.LoadUrl(url);
            return true;
        }

        public override void OnReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, string host, string realm)
        {
            Toast.MakeText(_context, "OnReceivedHttpAuthRequest: " + host, ToastLength.Long);
            handler.Proceed(Activity1.username, Activity1.password);
        }
    }
    //END DECLARATION

ATTEMPT 1: It does not even try to load the page. I keep getting an error:
chromium(18710): external/chromium/net/http/http_auth_gssapi_posix.cc:463: [0821/095922:WARNING:http_auth_gssapi_posix.cc(463)] Unable to find a compatible GSSAPI library

ATTEMPT 2: Does not show a single toast message.

I have already looked at:
http://developer.android.com/reference/android/webkit/WebView.html
Using WebView setHttpAuthUsernamePassword?
WebView.setHttpAuthUsernamePassword() not working?
Passing username and password to SSRS 2005 reports from web application

OTHER STUFF
I have now done it in Java and it works fine. I still need a Mono for Android solution:

public class Android_reporttestActivity extends Activity {
public static String username = "...";
public static String password = "...";
public static String website = "http://10.0.0.5/Reports";       

private WebView setupWebView()
{
    WebView webView = new WebView(this); 

    webView.setWebViewClient(
        new WebViewClient(){
            public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm)
            {                           
                handler.proceed(username,password);
            }
        }
    );

    return webView;
}

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    WebView webview = setupWebView();

    // Set our view from the "main" layout resource
    setContentView(webview);

    webview.loadUrl(website);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:50:17+00:00Added an answer on June 10, 2026 at 12:50 am

    Running the following for me allows everything to work as expected for me:

    [Activity (Label = "WebViewExample", MainLauncher = true)]
    public class Activity1 : Activity
    {
        string url;
        WebView mWebView;
    
        protected override void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);
    
            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);
    
            url = "http://awebsite.com"; 
            mWebView = (WebView)FindViewById<WebView> (Resource.Id.webview);
            mWebView.SetWebViewClient (new ViewClient (this));
            mWebView.Settings.JavaScriptEnabled = (true);
            mWebView.Settings.PluginsEnabled = (true);
            mWebView.LoadUrl (url);
        }
    
        class ViewClient : WebViewClient
        {
            Activity1 _activity;
    
            public ViewClient(Activity1 activity)
            {
                _activity = activity;   
            }
    
            public override void OnPageStarted (WebView view, string url, Android.Graphics.Bitmap favicon)
            {
                Console.WriteLine ("On Page Started");
            }
    
            public override void OnReceivedHttpAuthRequest (WebView view, HttpAuthHandler handler, string host, string realm)
            {
                Console.WriteLine ("On received Http auth request");
                handler.Proceed("username", "password");
            }
    
            public override bool ShouldOverrideUrlLoading (WebView view, string url)
            {
                Console.WriteLine ("Should Override Url Loading...");
                return base.ShouldOverrideUrlLoading (view, url);
            }
        }
    }
    

    The reason why your toasts aren’t showing is probably because you’re not calling “.Show()” on them so they are never displayed.

    If you still can’t get it up and running, then providing a URL we can use to hit against would be really useful.

    I hope this helps,

    ChrisNTR

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a list view containing two childs. Now i am trying to
I have made a simple test application for the issue, two winforms each containing
I have two UITextFields in the App as IBOutlets and I have made a
I have two branches: trunk, production. I have found a problem in trunk, made
I have these two images. And... I made them into graysclae images and then
I have searched for two weeks, every night, exhaustively reading forum threads and trying
I have made two thread running together with Netbeans and i want to add
I have made one custom user control (search text box), which basically consists of
I have made a jQuery toggle for a menu that I had in mind.
I have made an application for IPad in objective C. In this I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.