java - apache httpclient doesn't set basic authentication credentials -


have @ following code:

defaulthttpclient http = new defaulthttpclient();             http.getcredentialsprovider().setcredentials(                         new authscope(authscope.any_host, authscope.any_port),                          new usernamepasswordcredentials(                                                  configuration.username,                                                  configuration.developerkey ) );              httppost post = new httppost(strurl);             stringentity entity = new stringentity( ac.toxmlstring() );             entity.setcontenttype("text/xml");             post.setentity( entity );             org.apache.http.httpresponse response = http.execute( post ); 

it produces no errors. response server "no authorization header". checking request wireshark unveils there indeed no basic authentication set.

how possible?

okay, default basic authentication turned off. however, enabling far complicated (link) . therefore 1 can use code, works fine:

defaulthttpclient http = new defaulthttpclient(); httppost post = new httppost(strurl); usernamepasswordcredentials creds = new usernamepasswordcredentials(                     configuration.username,                      configuration.developerkey); post.addheader( basicscheme.authenticate(creds,"us-ascii",false) ); stringentity entity = new stringentity( ac.toxmlstring() ); entity.setcontenttype("text/xml"); post.setentity( entity ); org.apache.http.httpresponse response = http.execute( post ); 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -