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

Gebruik bestaande huurder-/kliëntbewyse. Waar openbare tussengangers vir beide die teken- en Graph-eindpunte toegelaat word, verskaf die HTTP-proksielys kandidate vir die gedeelde HTTP-proksiadres sonder rekening. Die openbare-wolk-scopes en toegelate gasheer hierbo moet by die beoogde wolkontplooiing pas.

httpClient(tokenHttp) verskaf Azure Identity se tekenroete. GraphClientFactory.create() behou Graph se verstek-middleware terwyl dit die API-proksi byvoeg; gebruik die finale graph-kliënt vir bewerkings.

'n Gemagtigde tussenganger vereis rekeningopstelling op beide paaie: Azure ProxyOptions.setCredentials en OkHttp proxyAuthenticator bedien hul onderskeie vervoerders. 'n Gekasde teken kan 'n ongekonfigureerde tekenpad verberg.

Behou en ruim vervoerders op wat jy besit saam met die komponent. Ouer TokenCredentialAuthProvider-bouers teiken 'n ander SDK-generasie.

Verwante artikels