I am trying to use Nodemailer in express server with Oauth from Office 365 but I am getting Can't create new access token for user and  {"code": "EAUTH", "command": "AUTH XOAUTH2" error. It seems like nodemailer is unable to obtain either the access token and refresh token and the user is not being authenticated to send mails.
  const transporter = nodemailer.createTransport({
    host: "smtp.office365.com",
    port: 587,
    secure: false,
    tls: {
      ciphers: "SSLv3"
    },
    requireTLS: true,
    auth: {
      type: "OAuth2",
      user: process.env.SENDER_EMAIL,
      clientId: "CLIENT_ID",
      clientSecret: "CLEINT_SECRET",
      accessUrl: "https://login.microsoftonline.com/SOMETHING_SECRET_HERE/oauth2/v2.0/authorize"
      // pass: process.env.SENDER_PASSWORD
    }
  });
I am not familiar with OAuth 2.0 with Office 365 to begin with so there could be some configurations error etc. The nodemailer works fine if I use my account credentials though. Can someone please suggest me something to try out or let me know if my config is wrong.



