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);

既存のテナント/クライアント資格情報を使用します。トークンと Graph の両方のエンドポイントでパブリックな中間プロキシが許可されている場合、HTTP プロキシ一覧が共有のアカウント不要 HTTP プロキシアドレスの候補を提供します。示されているパブリッククラウドのスコープと許可ホストは、想定するクラウド導入と一致している必要があります。

httpClient(tokenHttp) が Azure Identity のトークン ルートを提供します。GraphClientFactory.create() は Graph の既定のミドルウェアを維持したまま API プロキシを追加します。操作には最終的な graph クライアントを使用します。

認証付きの中間プロキシでは、両方の経路でアカウント設定が必要です。Azure の ProxyOptions.setCredentials と OkHttp の proxyAuthenticator がそれぞれのトランスポートを担います。キャッシュされたトークンは、未設定のトークン経路を隠す可能性があります。

所有するトランスポートはコンポーネントと共に保持し、後始末します。古い TokenCredentialAuthProvider ビルダーは別の SDK 世代を対象としています。

関連記事