Skip to content

ENH: Add Basic Authentication support - BasicAuthIntercept #19

Closed
@rbygrave

Description

@rbygrave

So to add basic authentication on every request sent add the BasicAuthIntercept like below:

Example

Where the username is rob and the password is bot ... create and register the BasicAuthIntercept like:

  public static HttpClientContext client() {

    BasicAuthIntercept basicAuthIntercept = new BasicAuthIntercept("rob", "bot")

    return HttpClientContext.newBuilder()
      .withBaseUrl(baseUrl)
      .withRequestListener(new RequestLogger())
      .withBodyAdapter(new JacksonBodyAdapter(new ObjectMapper()))
      
      .withRequestIntercept(basicAuthIntercept)     <!--  HERE !!!
      .build();
  }

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions