I'm trying to access some table data in a Sharepoint file hosted on botshop.cloudappsportal.com from an IBM Cloud Function written in Node.js.
I can access the REST API for Sharepoint on the site, but the authentication fails. My understanding, is that Sharepoint uses some complicated Microsoft authentication.
Here is the Node.js code,
const request = require('request-promise');
function main(params) {
var options = {
uri: "http://xxx.botshop.cloudappsportal.com/_api/web/lists/getbytitle('myfile')/items",
method: 'GET',
auth: {
'user': 'myuser@botshop.cloudappsportal.com',
'pass': 'password'
}
}
return request.get(options).then(response => {
return response;
});
}
exports.main = main;
I can access the URL from a browser, after it prompts for user/password.
I was also able to access it from Java, using the NTCredentials class.
HttpGet request = new HttpGet("http://xxx.botshop.cloudappsportal.com/_api/web/lists/getbytitle('myfile')/items");
HttpParams httpParams = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParams, 1000);
HttpConnectionParams.setSoTimeout(httpParams, 1000);
DefaultHttpClient client = new DefaultHttpClient(httpParams);
client.getCredentialsProvider().setCredentials(
new AuthScope(AuthScope.ANY),
new NTCredentials("myuser@botshop.cloudappsportal.com", "password", "", ""));
HttpResponse response = client.execute(request);
The normal UsernamePasswordCredentials did not work in Java, so I need the equivalent of NTCredentials in Node.js (that works inside IBM Cloud Functions). Any ideas?
Also somewhat odd that the extra arguments of the domain just "" "" works, so odd it needs the NTCredentials when it does not pass any additional useful data.