Java Enterprise SDK
The official Java module for secure rNet OAuth authentication and authenticated AI pipeline execution.
Mavenio.github.rnetai:rnet-oauth:1.0.3
Installation
xml
<dependency> <groupId>io.github.rnetai</groupId> <artifactId>rnet-oauth</artifactId> <version>1.0.3</version> </dependency>
JVM Requirements
The Java SDK leverages modern language features. It requires Java 21+ and utilizes the native
java.net.http.HttpClient, Jackson for JSON parsing, and SLF4J for logging.1. Initialize Clients
java
RNetOAuthConfig config = new RNetOAuthConfig(
System.getenv("RNET_CLIENT_ID"),
System.getenv("RNET_CLIENT_SECRET"),
"https://api.yourdomain.com/callback"
);
RNetOAuthClient auth = new RNetOAuthClient(config);
ModelClient gemini = new ModelClient(config, "gemini-2.5-flash-lite");2. Generate Cryptographic Challenge (PKCE)
java
PKCEUtil.PKCE pkce = auth.generatePKCE(); String codeVerifier = pkce.getVerifier(); // Persist in Redis/Session String authUrl = auth.getAuthorizationUrl(pkce.getChallenge(), "secure-random-state");
3. Exchange Code for Tokens
java
Map<String, Object> tokenResponse = auth.exchangeCodeForToken(authCode, codeVerifier);
String accessToken = (String) tokenResponse.get("access_token");
String refreshToken = (String) tokenResponse.get("refresh_token");4. Invoke AI Pipelines
java
Map<String, Object> payload = Map.of(
"contents", List.of(
Map.of("role", "user", "parts", List.of(Map.of("text", "Optimize this algorithm.")))
)
);
Map<String, Object> response = gemini.chat(payload, accessToken);
System.out.println(response);