title: Access Sharepoint document from Node.js in IBM Cloud Function
body: <p>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.</p>
  
  <p>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.</p>
  
  <p>Here is the Node.js code,</p>
  
  <pre><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 =&gt; {
          return response;
      });
  }
  
  exports.main = main;
  </code></pre>
  
  <p>I can access the URL from a browser, after it prompts for user/password.</p>
  
  <p>I was also able to access it from Java, using the NTCredentials class.</p>
  
  <pre><code>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);
  </code></pre>
  
  <p>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?</p>
  
  <p>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.</p>