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

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -