Java Sharepoint 在线服务的 NTLM 身份验证出现 401 错误

Java NTLM Athentication for sharepoint online services getting 401 error

我尝试使用以下代码从客户端共享点服务 (2013) 获取列表,它是一个 https(无效的证书),我下载了相同的证书并在 cacets.everytime 中安装了我得到以下响应

    try{
        HttpParams  params = new BasicHttpParams();
        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
        DefaultHttpClient httpClient = new DefaultHttpClient(params);
        httpClient.getAuthSchemes().register("ntlm", new NTLMSchemeFactory());
        httpClient.getCredentialsProvider().setCredentials(AuthScope.ANY, new 
        NTCredentials("username", "passwrd", "host", "domain"));
        HttpPut request = new HttpPut("https://domain/_api/get..");
        request.setHeader("Content-Type", "application/json;odata=verbose");
        request.setHeader("Accept", "application/json;odata=verbose");

        System.out.println(httpClient.execute(request));
    }catch(Exception e){
        throw e;
    }


 RESPONSE 

HTTP/1.1 401 Unauthorized [Server: Microsoft-IIS/8.5,
SPRequestGuid: 6ecb4d9f-9884-c0ba-7e4e-eed562a7e616,
request-id: 6ecb4d9f-9884-c0ba-7e4e-eed562a7e616,
X-FRAME-OPTIONS: SAMEORIGIN,
SPRequestDuration: 4,
SPIisLatency: 0,
WWW-Authenticate: NTLM,
X-Powered-By: ASP.NET,
MicrosoftSharePointTeamServices: 15.0.0.5172,
X-Content-Type-Options: nosniff,
X-MS-InvokeApp: 1;
RequireReadOnly,
Date: Thu,
30 Apr 2020 10:02:57 GMT,
Content-Length: 0] org.apache.http.conn.BasicManagedEntity@679b62af

我得到了解决方案 因为端口和主机名