code: protected static HttpClientBuilder addAuthentication(final HttpClientBuilder builder, 
              final URI uri, final String username,
              String password) {
          if (isNotBlank(username)) {
              CredentialsProvider provider = new BasicCredentialsProvider();
              AuthScope scope = new AuthScope(uri.getHost(), uri.getPort(), "realm");
              UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password);
              provider.setCredentials(scope, credentials);
              builder.setDefaultCredentialsProvider(provider);
  
              builder.addInterceptorFirst(new PreemptiveAuth());
          }
          return builder;
      }
docs: Add authentication to supplied builder.
  @param builder the builder to configure
  @param uri the server URI
  @param username the username
  @param password the password
  @return the passed in builder