REST Authentication in SharePoint 2013

I plan to do the work, encoded in Java, on a Linux server, which is supposed to upload the file to SharePoint on the spot in 2013 once a day using the REST API. How can I authenticate this client work? I have googled, but I'm still trying to get a clear overview of my options.

+5
source share
1 answer

They have two ways to do this. You can use one of them using the SharePoint / Add-In application model, and the other using network authentication with Windows credentials. Given this question, I assume the latter will be simpler and better match the setup.

This will create Windows authentication credentials that you can use for your HTTP requests.

RequestConfig reqConfig = RequestConfig.custom().setTargetPreferredAuthScemes(Arrays.asList(AuthSchemes.NTLM)).setProxyPreferredAuthSchemes(Arrays.asList(AuthSchemes.BASIC)).build(); CredentialsProvider credProvider = new BasicCredentialsProvider(); credProvider.setCredentials(AuthSocpe.ANY, new NTCredentials("user", "pass", "currentHost", "domainName")); HttpClient client = HttpClients.custom().setDefaultCredentialsProvider(credProvider).setDefaultRequestConfig(reqConfig).build(); // construct your http request HttpResponse response = client.execute(HttpHost, HttpPost); 
+1
source

Source: https://habr.com/ru/post/1265491/


All Articles