Abhishek Bansal
Abhishek Bansal

Reputation: 1

How to implement NTLM auth with ews-javascript-api package?

I'm currently working on a project where I need to fetch emails from Outlook using the ews-javascript-api package. While I've successfully implemented basic authentication, I'm encountering difficulties with NTLM.

Here's the relevant section of my code:

const ews = require('ews-javascript-api');
const {XhrApi} = require('@ewsjs/xhr');

let username = "", password = "", auth = "NTLM", host = "";
let exVersion = 7;

const xhr = new XhrApi({
gzip: true,
rejectUnauthorized: false
});

if (auth.toLowerCase() === 'ntlm') {
xhr.useNtlmAuthentication(username, password);
ews.ConfigurationApi.ConfigureXHR(xhr);
}

let exch = new ews.ExchangeService(exVersion);
exch.Url = new ews.Uri(host);
exch.Credentials = new ews.WebCredentials(username, password);

However, when I attempt to use exch.FindItems(id, filter, count), I receive the error "www-authenticate not found on response of the second request."

I'd appreciate any insights or guidance on how to resolve this issue. Thank you!

Upvotes: 0

Views: 100

Answers (0)

Related Questions