i want use spring boot , integration dsl send messages http post rest service. have example of how (basic) authentication?
everything else seems working fine. log shows "org.springframework.web.client.httpclienterrorexception: 401 unauthorized".
actually there nothing basic auth
spring integration side.
this responsibility of clienthttprequestfactory
.
for example used this:
@bean public clienthttprequestfactory clienthttprequestfactory(@value("username") string username, @value("password") string password) { httpclient httpclient = httpclientbuilder.create(). setdefaultcredentialsprovider(getcredentialsprovider(username, password)) .build(); httpcomponentsclienthttprequestfactory clienthttprequestfactory = new httpcomponentsclienthttprequestfactory(httpclient); return clienthttprequestfactory; } private credentialsprovider getcredentialsprovider(final string username, final string password) { credentialsprovider cp = new basiccredentialsprovider(); cp.setcredentials(new authscope(authscope.any_host, authscope.any_port), new usernamepasswordcredentials(username, password)); return cp; }
and inject clienthttprequestfactory
http.outboundgateway().requestfactory()
.
all other clienthttprequestfactory
may have ways configure basic auth
requests objects.
Comments
Post a Comment