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

გამოიყენეთ არსებული tenant/client-ის სერტიფიკატები. სადაც საჯარო შუამავლები ნებადართულია როგორც token-ის, ისე Graph-ის ბოლო წერტილებისთვის, HTTP პროქსის სია გთავაზობთ კანდიდატებს საერთო ანგარიშის გარეშე HTTP პროქსის მისამართისთვის. ნაჩვენები საჯარო ღრუბლის scope-ები და დაშვებული ჰოსტი უნდა შეესაბამებოდეს დაგეგმილ ღრუბლოვან განლაგებას.

httpClient(tokenHttp) უზრუნველყოფს Azure Identity-ის token მარშრუტს. GraphClientFactory.create() ინარჩუნებს Graph-ის ნაგულისხმევ middleware-ს და ამატებს API პროქსის; ოპერაციებისთვის გამოიყენეთ საბოლოო graph კლიენტი.

ავთენტიფიცირებული შუამავალი მოითხოვს ანგარიშის კონფიგურაციას ორივე გზაზე: Azure ProxyOptions.setCredentials და OkHttp proxyAuthenticator ემსახურება მათ შესაბამის ტრანსპორტებს. ქეშირებულმა token-მა შეიძლება დამალოს არაკონფიგურირებული token-ის გზა.

შეინარჩუნეთ და გაასუფთავეთ საკუთარი ტრანსპორტები კომპონენტთან ერთად. ძველი TokenCredentialAuthProvider builder-ები მიმართულია SDK-ის სხვა თაობაზე.

დაკავშირებული სტატიები