0

I am using following code

 public void executeHttpGet() throws Exception {
    dialog = new ProgressDialog(this);
    dialog.setCancelable(true);

    // set a message text
    dialog.setMessage("Loading...");

    // show it
    dialog.show();
     BufferedReader in = null;

            HttpClient client = new DefaultHttpClient();
            HttpGet request = new HttpGet();
         String url=   "http://newdev.objectified.com/morris/interface/mobile.php?method=dealerLogin&username=alixxxxxxxx&password=jamali";


            request.setURI(new URI(url));
            HttpResponse response = client.execute(request);
            in = new BufferedReader
            (new InputStreamReader(response.getEntity().getContent()));
            StringBuffer sb = new StringBuffer("");
            String line = "";
            String NL = System.getProperty("line.separator");
            while ((line = in.readLine()) != null) {
                sb.append(line + NL);
            }
            in.close();
            String page = sb.toString();
            Toast.makeText(this, page, Toast.LENGTH_LONG).show();
         //  dialog.dismiss();


    }

Now I want to do http authentication on this ,please help?

2 Answers 2

2

It should look like this:

     HttpClient client = new DefaultHttpClient();
     HttpGet request = new HttpGet();
     String url=   "http://newdev.objectified.com/morris/interface/mobile.php?method=dealerLogin&username=alixxxxxxxx&password=jamali";

     String login = "alixxxxxxxx";
     String pass = "jamali";

     client.getCredentialsProvider().setCredentials(new AuthScope("newdev.objectified.com", 80), new UsernamePasswordCredentials(login, pass));

     request.setURI(new URI(url));
     HttpResponse response = client.execute(request);
Sign up to request clarification or add additional context in comments.

1 Comment

HttpClient has no method named asgetCredentialsProvider()
0

For http authentication the Authenticator class is your friend.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.