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, ລາຍຊື່ proxy HTTP ສະໜອງຜູ້ສະໝັກສຳລັບທີ່ຢູ່ proxy HTTP ຮ່ວມທີ່ບໍ່ມີບັນຊີ. scope ຂອງ cloud ສາທາລະນະ ແລະ host ທີ່ອະນຸຍາດທີ່ສະແດງຕ້ອງກົງກັບການຕິດຕັ້ງ cloud ທີ່ຕັ້ງໃຈ.

httpClient(tokenHttp) ສະໜອງເສັ້ນທາງ token ຂອງ Azure Identity. GraphClientFactory.create() ຮັກສາ middleware ເລີ່ມຕົ້ນຂອງ Graph ໃນຂະນະທີ່ເພີ່ມ proxy ຂອງ API; ໃຊ້ລູກຄ້າ graph ສຸດທ້າຍສຳລັບການດຳເນີນງານ.

ຕົວກາງທີ່ຢືນຢັນຕົວຕົນແລ້ວຕ້ອງການການຕັ້ງບັນຊີໃນທັງສອງເສັ້ນທາງ: Azure ProxyOptions.setCredentials ແລະ OkHttp proxyAuthenticator ໃຫ້ບໍລິການການຂົນສົ່ງຂອງຕົນ. token ທີ່ເກັບໄວ້ໃນ cache ສາມາດປິດບັງເສັ້ນທາງ token ທີ່ຍັງບໍ່ໄດ້ຕັ້ງຄ່າ.

ຮັກສາ ແລະ ທຳຄວາມສະອາດການຂົນສົ່ງທີ່ເປັນເຈົ້າຂອງກັບ component. builder TokenCredentialAuthProvider ເກົ່າກວ່າເປົ້າໝາຍ SDK ອີກລຸ້ນໜຶ່ງ.

ບົດຄວາມທີ່ກ່ຽວຂ້ອງ