在 nodemailer 中通过 gmail oauth 发送电子邮件需要哪个范围?

Which scope is required to send emails through gmail oauth in nodemailer?

我已经设置了 google 帐户的身份验证,我能够获得用户的访问和刷新令牌,但是当我将范围设置为仅 https://www.googleapis.com/auth/gmail.send it doesn't work but when I set the authentication scope to https://mail.google.com/ 时,它可以正常工作。这里发生了什么?为什么我不能只使用发送范围通过 nodemailer 发送电子邮件?这是我的代码:-

var nodemailer = require('nodemailer');

let transporter = nodemailer.createTransport({
    host: 'smtp.gmail.com',
    port: 587,
    secure: false,
    requireTLS: true,
    auth: {
        type: 'OAuth2',
        clientId: 'my_client_id',
        clientSecret: 'my_client_secret'
    }
});

transporter.sendMail({
    from: 'user@gmail.com',
    to: 'target@gmail.com',
    subject: 'Message',
    text: 'Hi there',
    auth: {
        user: 'user@gmail.com',
        refreshToken: 'user_refresh_token',
        accessToken: 'user_access_token'
    }
}).catch(error => {
    console.log(error);
});

Nodemailer 文档中有一条注释说范围必须是 'https://mail.google.com/':https://nodemailer.com/smtp/oauth2/#troubleshooting

而这里实际上是由Google指定的:https://developers.google.com/gmail/imap/xoauth2-protocol