Basic Http Authication

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

Basic Http Authication

Postby Radzell » Fri Aug 21, 2009 9:36 pm

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. private void Authication() throws Exception {
  2.  
  3.             // TODO Auto-generated method stub
  4.  
  5.             DefaultHttpClient client = new DefaultHttpClient();
  6.  
  7.                client.getCredentialsProvider().setCredentials(
  8.  
  9.                         new AuthScope("api.cliqset.com", 200),
  10.  
  11.                         new UsernamePasswordCredentials("Radzell", "Radzell1"));
  12.  
  13.               String login = "api.cliqset.com";
  14.  
  15.               URI uri = null;
  16.  
  17.             try {
  18.  
  19.                 uri = new URI(login);
  20.  
  21.             } catch (URISyntaxException e) {
  22.  
  23.                 // TODO Auto-generated catch block
  24.  
  25.                 e.printStackTrace();
  26.  
  27.             }
  28.  
  29.                HttpGet method = new HttpGet(uri);
  30.  
  31.                method.addHeader("CliqsetConsumerKey",
  32.  
  33.                                 Consumerkey);
  34.  
  35.                HttpResponse res = null;
  36.  
  37.             try {
  38.  
  39.                 res = client.execute(method);
  40.  
  41.             } catch (ClientProtocolException e) {
  42.  
  43.                 // TODO Auto-generated catch block
  44.  
  45.                 e.printStackTrace();
  46.  
  47.             } catch (IOException e) {
  48.  
  49.                 // TODO Auto-generated catch block
  50.  
  51.                 e.printStackTrace();
  52.  
  53.             }
  54.  
  55.                Log.i("log file",res.toString());
  56.  
  57.             }
  58.  
  59.         }
Parsed in 0.035 seconds, using GeSHi 1.0.8.4

I can figure out why i keep getting this error this is my second attempt first was with Oauth i can get any authication to work with Android can someone help.
Radzell
Developer
Developer
 
Posts: 45
Joined: Thu Aug 20, 2009 8:14 am

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 9 guests