var address = new java.net.InetSocketAddress("proxy.example", 8080);
var tokenProxy = new com.azure.core.http.ProxyOptions(
    com.azure.core.http.ProxyOptions.Type.HTTP, address);
var tokenHttp = new com.azure.core.http.netty.NettyAsyncHttpClientBuilder()
    .proxy(tokenProxy).build();
var credential = new com.azure.identity.ClientSecretCredentialBuilder()
    .tenantId(tenantId).clientId(clientId).clientSecret(clientSecret)
    .httpClient(tokenHttp).build();

String[] scopes = {"https://graph.microsoft.com/.default"};
String[] allowedHosts = {"graph.microsoft.com"};
var auth = new com.microsoft.kiota.authentication.AzureIdentityAuthenticationProvider(
    credential, allowedHosts, scopes);
var graphHttp = com.microsoft.graph.core.requests.GraphClientFactory.create()
    .proxy(new java.net.Proxy(java.net.Proxy.Type.HTTP, address))
    .build();
var graph = new com.microsoft.graph.serviceclient.GraphServiceClient(auth, graphHttp);

Use existing tenant/client credentials. Where public intermediaries are permitted for both the token and Graph endpoints, the HTTP proxy list supplies candidates for the shared no-account HTTP proxy address. The public-cloud scopes and allowed host shown must match the intended cloud deployment.

httpClient(tokenHttp) supplies Azure Identity's token route. GraphClientFactory.create() keeps Graph's default middleware while adding the API proxy; use the final graph client for operations.

An authenticated intermediary needs account setup on both paths: Azure ProxyOptions.setCredentials and OkHttp proxyAuthenticator serve their respective transports. A cached token can hide an unconfigured token path.

Retain and clean up owned transports with the component. Older TokenCredentialAuthProvider builders target another SDK generation.

Artihkkalat mat laktásit