Socruithe seachfhreastalaí Microsoft Graph Java 6 do chliaint API agus comhartha
Úsáid bealach Netty Azure Identity agus bealach OkHttp Graph a choinníonn an middleware le linn an túsaithe.
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);Úsáid dintiúirí tionónta/cliant atá ann cheana. Nuair a cheadaítear idirghabhálaithe poiblí don chomhartha agus do chríochphointí Graph araon, soláthraíonn an liosta seachfhreastalaithe HTTP iarrthóirí don seoladh HTTP comhroinnte gan chuntas. Caithfidh na scóip scamall poiblí agus an t-óstach ceadaithe a thaispeántar a bheith ag teacht leis an imscaradh scamall atá beartaithe.
Soláthraíonn httpClient(tokenHttp) bealach comhartha Azure Identity. Coinníonn GraphClientFactory.create() middleware réamhshocraithe Graph agus cuireann sé seachfhreastalaí an API leis; úsáid an cliant deiridh graph le haghaidh oibríochtaí.
Teastaíonn socrú cuntais ar an dá bhealach ó idirghabhálaí fíordheimhnithe: freastalaíonn Azure ProxyOptions.setCredentials agus OkHttp proxyAuthenticator ar a n-iompróirí féin. Is féidir le comhartha i dtaisce bealach comhartha neamhchumraithe a cheilt.
Coinnigh agus glan iompróirí faoi úinéireacht leis an gcomhpháirt. Dírítear tógálaithe TokenCredentialAuthProvider níos sine ar ghlúin SDK eile.