Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

300
Views
NodeJs can't authenticate over NTLM

We are using httpntlm (https://www.npmjs.com/package/httpntlm) library in order to authenticate with NTLM.

We are following the 3 steps of the protocol as example:

var ntlm = require('httpntlm').ntlm;
var async = require('async');
var httpreq = require('httpreq');
var HttpsAgent = require('agentkeepalive').HttpsAgent;
var keepaliveAgent = new HttpsAgent();

var options = {
    url: "https://someurl.com",
    username: 'm$',
    password: 'stinks',
    workstation: 'choose.something',
    domain: ''
};

async.waterfall([
function (callback){
    var type1msg = ntlm.createType1Message(options);

    httpreq.get(options.url, {
        headers:{
            'Connection' : 'keep-alive',
            'Authorization': type1msg
        },
        agent: keepaliveAgent
    }, callback);
},

function (res, callback){
    if(!res.headers['www-authenticate'])
        return callback(new Error('www-authenticate not found on response of second request'));

    var type2msg = ntlm.parseType2Message(res.headers['www-authenticate']);
    var type3msg = ntlm.createType3Message(type2msg, options);

    setImmediate(function() {
        httpreq.get(options.url, {
            headers:{
                'Connection' : 'Close',
                'Authorization': type3msg
            },
            allowRedirects: false,
            agent: keepaliveAgent
        }, callback);
    });
}
], function (err, res) {
    if(err) return console.log(err);

    console.log(res.headers);
    console.log(res.body);
});

We get 401 in the first 2 calls, then the last one responses with 400 BadRequest. If I use Postman with NTLM authentication and I inspect the requests, the last call works and I get 200. (I've tried also axios-ntlm (https://www.npmjs.com/package/axios-ntlm) and I get the same error.

have you guys had this problem befor by any chance?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!