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 ដែលមានស្រាប់។ នៅកន្លែងដែលអនុញ្ញាតឱ្យមានអន្តរការីសាធារណៈសម្រាប់ទាំងចំណុចបញ្ចប់តូខេន និង Graph បញ្ជីប្រូកស៊ី HTTP ផ្តល់បេក្ខជនសម្រាប់អាសយដ្ឋានប្រូកស៊ី HTTP រួមដោយគ្មានគណនី។ scope នៃពពកសាធារណៈ និង host ដែលបានអនុញ្ញាតដែលបានបង្ហាញត្រូវតែត្រូវគ្នានឹងការដាក់ពង្រាយពពកដែលបានគ្រោងទុក។

httpClient(tokenHttp) ផ្តល់ផ្លូវតូខេនរបស់ Azure Identity។ GraphClientFactory.create() រក្សា middleware លំនាំដើមរបស់ Graph ខណៈពេលបន្ថែមប្រូកស៊ី API; ប្រើអតិថិជន graph ចុងក្រោយសម្រាប់ប្រតិបត្តិការ។

អន្តរការីដែលបានផ្ទៀងផ្ទាត់ត្រូវការការរៀបចំគណនីលើផ្លូវទាំងពីរ៖ Azure ProxyOptions.setCredentials និង OkHttp proxyAuthenticator បម្រើការដឹកជញ្ជូនរៀងៗខ្លួន។ តូខេនដែលបានឃ្លាំងសម្ងាត់អាចបាំងផ្លូវតូខេនដែលមិនបានកំណត់។

រក្សា និងសម្អាតការដឹកជញ្ជូនដែលអ្នកគ្រប់គ្រងជាមួយសមាសធាតុ។ អ្នកសាងសង់ TokenCredentialAuthProvider ចាស់ជាង សំដៅលើជំនាន់ SDK ផ្សេង។

អត្ថបទពាក់ព័ន្ធ