Node.js integration with MS Exchange EWS

AngryMonkey picture AngryMonkey · Feb 8, 2012 · Viewed 13.6k times · Source

I am attempting to use Node.js to call the SOAP Exchange EWS services. I have created a simple http client like so:

var https = require('https');

var username = 'user';
var password = 'password';
var auth = 'NTLM ' + new Buffer(username + ":" + password).toString('base64');

var options = {
    host : 'exchangehost',
    port : 443,
    method : 'post',
    path : '/Exchange.asmx',
    headers : { Authorization : auth }
};

var request = https.request(options, function(response) {
    console.log('Status: ' + response.statusCode);
};

request.write('<soapenv:Envelope  ...></soapenv:Envelope>');
request.end();

I receive a status code 401, I suspect because I am not doing the three steps involved for NTLM authentication (http://www.innovation.ch/personal/ronald/ntlm.html). Does anyone know of a Node.js module for communicating with Exchange EWS directly or for authenticating using NTLM, or am I going to need to implement that protocol for Node.js myself? Any assistance is greatly appreciated.

Answer

Jason picture Jason · Jun 16, 2015

Have you tried the httpntlm module? https://github.com/SamDecrock/node-http-ntlm