jgritman / httpbuilder

315 stars 154 forks source link

Basic authentication #79

Closed walshe closed 7 years ago

walshe commented 7 years ago

Hi,

how can I pass along 'Basic' authentication details like username and password like I would do like follows with Java/Jersey ?

        ClientConfig clientConfig = new ClientConfig();

        HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic(username, password);
        clientConfig.register(feature);

        clientConfig.register(JacksonFeature.class);

        Client client = ClientBuilder.newClient(clientConfig);
        WebTarget webTarget = client.target("xxxxxxxx");

        Invocation.Builder invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON);
walshe commented 7 years ago

figured it out

def http = new HTTPBuilder('https://xyx')
http.auth.basic(username, password)