Skip to content

Allow custom OkHttpClient configuration via ApiConfiguration #2

Description

Currently, the SDK instantiates OkHttpClient internally with no timeout or interceptor configuration:

// HttpClient.java (internal)                                                                                                                                                                     
this.httpClient = new OkHttpClient();

ApiConfiguration.builder() only exposes url and accessToken, leaving no public API to configure the underlying HTTP client. This means users cannot set connect/read/write timeouts, add interceptors, configure retries, or customize TLS.

Suggested fix: Accept an optional OkHttpClient in the builder:

ApiConfiguration.builder()
    .url(...)
    .accessToken(...)
    .httpClient(myConfiguredClient)  // optional, falls back to new OkHttpClient()
    .build();

The openapi-generator's ApiClient is a good reference. It supports both a constructor that accepts a pre-built OkHttpClient and individual setter methods for timeouts.

As a current workaround, one could use reflection to replace the private field after instantiation, which is fragile across SDK versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions