I am trying to convert some old style Groovy HttpBuilder code to HttpBuilder-NG. One thing I had to do in old style was to add request interceptor to handle the basic authorization. This is how I did it in the old HttpBuilder
def http = new RESTClient(url)
http.client.addRequestInterceptor(new HttpRequestInterceptor() {
void process(HttpRequest httpRequest, HttpContext httpContext) {
log.debug("Request intercepted, adding authorization")
httpRequest.addHeader('Authorization','Basic ' + "${username}:${password}".bytes.encodeBase64().toString())
}
})
return http
How should it be done in HttpBuilder-NG? (and yes I've been reading the User Guide).
Updated 16/May/2017
I ask because using the ApacheHttpBuilder it get this in the log.
DEBUG - Authentication required
DEBUG - gpdevjira.broadinstitute.org:8443 requested authentication
DEBUG - Authentication schemes in the order of preference: [Negotiate, Kerberos, NTLM, Digest, Basic]
DEBUG - Challenge for Negotiate authentication scheme not available
DEBUG - Challenge for Kerberos authentication scheme not available
DEBUG - Challenge for NTLM authentication scheme not available
DEBUG - Challenge for Digest authentication scheme not available
DEBUG - Challenge for Basic authentication scheme not available
I was able to use the old HttpBuilder with the request interceptor to handle the Basic authentication.