请我有 nodemailer 的 gmail api,但我的邮件在一周后停止工作。我已经遵循了所有流程并做了所有事情,但仍然得到了未授权的客户端。我认为刷新令牌不起作用...
这是我的代码。
"
const oAuth2Client = new google.auth.OAuth2(process.env.CLIENT_ID, process.env.CLIENT_SECRET, process.env.REDIRECT_URI);
oAuth2Client.setCredentials({
refresh_token: process.env.REFRESH_TOKEN
});
const accessToken = oAuth2Client.getAccessToken();
let transporter = nodemailer.createTransport({
service: 'gmail',
tls: {
rejectUnauthorized: false
},
auth: {
type: 'OAuth2',
user: 'merkadobarkada21@gmail.com',
pass: 'mypass123',
clientId: process.env.CLIENT_ID,
clientSecret: process.env.CLIENT_SECRET,
refreshToken: process.env.REFRESH_TOKEN,
accessToken: accessToken
}
});"