Updated all Java examples to use the new addHeader method for adding authentication headers, simplifying how Sandbox authentication headers are set in Java applications.

java-headers.diff
1--- java-client-before.java 2025-09-05 10:00:00
2+++ java-client-after.java 2025-09-05 10:30:00
3@@ -1,19 +1,11 @@
4 import com.anduril.Lattice;
5-import okhttp3.OkHttpClient;
6
7 public class LatticeClientExample {
8 public static void main(String[] args) {
9 String endpoint = System.getenv("LATTICE_ENDPOINT");
10 String token = System.getenv("ENVIRONMENT_TOKEN");
11 String sandboxesToken = System.getenv("SANDBOXES_TOKEN");
12-
13- // Create HTTP client with Sandbox authentication
14- OkHttpClient httpClient = new OkHttpClient.Builder()
15- .addInterceptor(chain -> {
16- return chain.proceed(chain.request().newBuilder()
17- .header("Anduril-Sandbox-Authorization", "Bearer " + sandboxesToken)
18- .build());
19- })
20- .build();
21-
22+
23+ // Create Lattice client with Sandbox authentication
24 Lattice client = Lattice.builder()
25 .url(endpoint)
26 .token(token)
27- .httpClient(httpClient)
28+ .addHeader("Anduril-Sandbox-Authorization", "Bearer " + sandboxesToken)
29 .build();
30 }
31 }

Java SDK Improvements

The Lattice SDK for Java 2.3.0 introduces a simplified approach for adding authentication headers to API requests:

  • Added new addHeader method to the Lattice client builder that eliminates the need to create custom OkHttpClient instances.
  • Updated all Java examples to use this new approach, resulting in cleaner, more maintainable code.
  • Removed boilerplate OkHttpClient interceptor configuration that was previously required.