nodemailer OAuth2 gsuite (mail@example.com) serviceClient 和 privateKey 配置

nodemailer OAuth2 gsuite (mail@example.com) serviceClient and privateKey config

Nodemailer documentation for 2LO 声明您可以这样进行配置设置:注意我使用的是网络唯一地址 example.com,它是使用 gsuite 托管的电子邮件:

host: 'smtp.gmail.com',
port: 465,
secure: true,
auth: {
  auth: 'OAuth2',
  user: 'mail@example.com',
  serviceClient: emailKey.client_id,
  privateKey: emailKey.private_key,
}

并且您可以根据most up-to-date tutorial I can find使用正确的配置创建一个gcp服务帐户。但是它给出了这个错误:

Error: Missing credentials for "PLAIN" ... code: 'EAUTH', command: 'API'

此问题暂无解决,here供参考

我发现的相关堆栈溢出问题中的所有“已接受的答案”都已过时,因为 GCP 服务帐户的 JSON 输出不再包含刷新和访问令牌。 虽然看起来像是特定于 Gmail 的。

有什么推荐吗?我是否需要使用访问令牌设置?因为我找不到有关如何执行此操作的良好文档。也许是相关的 google 文档,因为我无法区分哪些是针对唯一网址的,哪些是特定于 @gmail.com 的。

您输入的是 auth: 'OAuth2' 而不是 type: 'OAuth2'