i have a problem with your api, with the same config i tried fetch directly and it managed to read my inbox, for some reason after i moved Credentials from ews.ExchangeCredentials to ews.OAuthCredentials, it becomes a problem:
const msal = require('@azure/msal-node');
const main = async () => {
const msalConfig = {
auth: {
clientId: "xx",
authority: "https://login.microsoftonline.com/xx",
clientSecret: "xx",
}
};
const usernamePasswordRequest = {
scopes: ["user.read"],
username: "xx@xx.com", // Add your username here
password: "123123", // Add your password here
};
const pca = new msal.PublicClientApplication(msalConfig);
const getToken = async () => {
return await pca.acquireTokenByUsernamePassword(usernamePasswordRequest)
}
const token = await getToken()
console.log(token)
var { ExchangeService, Uri, OAuthCredentials, ExchangeVersion, Folder, WellKnownFolderName, EwsLogging } = require("ews-javascript-api");
EwsLogging.DebugLogEnabled = false;
var exch = new ExchangeService(ExchangeVersion.Exchange2016);
exch.Url = new Uri("https://outlook.office365.com/ews/exchange.asmx");
exch.Credentials = new OAuthCredentials(token.accessToken);
await Folder.Bind(exch, WellKnownFolderName.Inbox);
}
main()
Hi Gautamsi,
i have a problem with your api, with the same config i tried fetch directly and it managed to read my inbox, for some reason after i moved Credentials from ews.ExchangeCredentials to ews.OAuthCredentials, it becomes a problem:
with the same config, I used the code from https://docs.microsoft.com/en-us/azure/active-directory/develop/tutorial-v2-nodejs-console and it worked. I really hope for your help. thank you very much