Google oauth 2.0 API password change Username and Password not accepted
@sambellerose I went from
const generator = xoauth2.createXOAuth2Generator({
user: serverConfig.gmail.client_user,
clientId: serverConfig.gmail.client_id,
clientSecret: serverConfig.gmail.secret,
refreshToken: serverConfig.gmail.refresh_token,
accessToken: serverConfig.gmail.access_token,
});
const transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
xoauth2: generator,
},
});
To just having the following:
const transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
type: 'OAuth2',
user: serverConfig.gmail.client_user,
clientId: serverConfig.gmail.client_id,
clientSecret: serverConfig.gmail.secret,
refreshToken: serverConfig.gmail.refresh_token,
accessToken: serverConfig.gmail.access_token,
},
});
I hope this helps
I solved this by updating to latest version of Nodemailer, and remove xoauth2 module as Nodemailer 3 has better Oauth 2 support. Going on Google Oauth 2.0 playground I able to get correct access and refresh tokens.