Whether have enough permissions to the user, password, SSL certificate is needed?
Tried a lot of methods, returns are Access denied.
Nasty, consult
CodePudding user response:
Can skip the SSL certificate authentication this step?CodePudding user response:
The String url="https://site/_api/web/title";Map
ParamHeader. Put (" Accept ", "application/XML");
Map
ParamBody. Put (" client_id ", "test");
ParamBody. Put (" client_secret ", "ttest");
//the String result=HTTPSClientUtil. DoGet (httpClient, url, paramHeader, paramBody);
The String result=HTTPSClientUtil. DoGet (httpClient, url, null, null);
System. The out. Println (" @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ ");
System.out.println(result);
CodePudding user response:
Public void prepareCertificate () throws the Exception {System. The out. Println (" # # # # # # # # # # # # # # # # # # # # # # # # ");
//skip certificate validation
SSLContext CTX=SSLContext. GetInstance (" SSL ");
X509TrustManager tm=new X509TrustManager () {
@ Override
Public void checkClientTrusted (X509Certificate [] chain, String authType) throws CertificateException {
}
@ Override
Public void checkServerTrusted (X509Certificate [] chain, String authType) throws CertificateException {
}
@ Override
Public X509Certificate [] getAcceptedIssuers () {
return null;
}
};
//set to have the trust certificate
CTX. Init (null, new TrustManager []} {tm, null);
Enclosing connectionSocketFactory=new SSLConnectionSocketFactory (CTX);
}
CodePudding user response:
You it's not a question of certificate, client access rest API, need take authorized to visit, with authorization method in asp.net, don't know whether Java has a similar method;Give you an example of a net consult, you try to translate into Java
Uri Uri=new Uri (siteURL + "/_api/web/");
NetworkCredential nc=new NetworkCredential (" admin ", "pass - 1234", "domain");
HttpWebRequest request=(HttpWebRequest) WebRequest. Create (uri);
Request. The Method="GET";
Request. Credentials=nc;
HttpWebResponse response=(HttpWebResponse) request. The method GetResponse ();
Stream, Stream=response. GetResponseStream ();
CodePudding user response:
Java inside also is to have the authorization