Roghainnean proxy Microsoft Graph Java 6 airson luchd-dèiligidh API is token
Cleachd slighe Netty Azure Identity agus slighe OkHttp Graph a ghlèidheas am middleware rè an tòiseachaidh.
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);Cleachd teisteanasan luchd-gabhail/luchd-dèiligidh a th' ann mu thràth. Far a bheil eadar-mheadhanairean poblach ceadaichte airson an dà chuid an token agus na h-àiteachan-deiridh Graph, bheir an liosta proxy HTTP tagraichean airson an t-seòladh HTTP co-roinnte gun chunntas. Feumaidh na raointean sgòthan poblach agus an t-òstair ceadaichte a chithear a bhith a' freagairt don chleachdadh sgòthan a thathar an dùil.
Bheir httpClient(tokenHttp) slighe token Azure Identity. Glèidhidh GraphClientFactory.create() middleware bunaiteach Graph fhad 's a chuireas e proxy an API ris; cleachd an neach-dèiligidh mu dheireadh graph airson obrachaidhean.
Feumaidh eadar-mheadhanaire le dearbhadh suidheachadh cunntais air an dà shlighe: frithealaidh Azure ProxyOptions.setCredentials agus OkHttp proxyAuthenticator an luchd-giùlain fa leth. Faodaidh token tasgaidh slighe token neo-rèitichte fhalach.
Glèidh agus glan luchd-giùlain ann an sealbh leis a' cho-phàirt. Tha luchd-togail TokenCredentialAuthProvider nas sine ag amas air ginealach SDK eile.