I am running the following script in a Windows command prompt with node myscript.js
. The script requests a web application which is using Windows Authentication. I expect to receive status code 200. But the script returns a 401 Unauthenticated
.
let request = require('request');
console.log(process.env.USERDOMAIN);
console.log(process.env.USERNAME);
request('http://internalurl',
function (error, response, body){
if (!error && response.statusCode == 200){
console.log('request successful!');
var input = JSON.parse(body);
}
console.log(response);
});
The process.env.USERNAME
displays my current username which should have access to the web application. Because of this I am assuming that the script is running under the correct user account. What is the best practice to login into the web application?