Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

299
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda