Tecnologia do Blogger.
RSS

Re: [androidbrasil-dev] Basic Authentication no Android

Da onde vem UsernamePasswordCredentials? e qual é essa variavel request? Pode me dar um exemplo melhor?


2013/9/26 Buiu <buiucardoso@gmail.com>
Talvez ajude: 

import org.apache.http.auth.UsernamePasswordCredentials;

import org.apache.http.impl.auth.BasicScheme;


Cristian Cardoso
www.ctncar.com.br


2013/9/26 Buiu <buiucardoso@gmail.com>
tenta assim:

UsernamePasswordCredentials creds = new UsernamePasswordCredentials(

username, password);

request.addHeader(new BasicScheme().authenticate(creds, request));



Cristian Cardoso
www.ctncar.com.br


2013/9/26 Ricardo Cardoso <rick.duk@gmail.com>

Olá, preciso fazer uma conexão Basic authencitation porém está retornando um erro: Not acceptable segue o código que eu estou usando

DefaultHttpClient httpClient = new DefaultHttpClient();

ResponseHandler resonseHandler = new BasicResponseHandler();

HttpPost postMethod = new HttpPost(URL_SERVIDOR_TESTE);

postMethod.setHeader( "Content-Type", "application/xml");

String credentials = "USER" + ":" + "USER";

String authorizationString = "Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP);

postMethod.setHeader("Authorization", authorizationString);

String response = null;

try {

response = httpClient.execute(postMethod,resonseHandler);

Log.d("LOG", "RESPOSTA: "+ response);

} catch (Exception e) {

Log.d("LOG", "RESPOSTA: "+ e.getLocalizedMessage());

}

Será que alguém pode me ajudar?

--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--






--



--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 comentários:

Postar um comentário