nodemailer OAuth2 gsuite ([email protected]) serviceClient and privateKey config

130 Views Asked by At

Nodemailer documentation for 2LO states you can make a config setup as such: Note I'm using a web unique address example.com which is email-hosted with gsuite:

host: 'smtp.gmail.com',
port: 465,
secure: true,
auth: {
  auth: 'OAuth2',
  user: '[email protected]',
  serviceClient: emailKey.client_id,
  privateKey: emailKey.private_key,
}

And you can make a gcp service account with the right config according to the most up-to-date tutorial I can find. However it gives this error:

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

There are no solved issues on this, here is one for reference.

All "Accepted answers" in related stack overflow questions I found are out of date since the JSON output from GCP service account no longer includes refresh and access tokens. This one though looks like its gmail specific.

Any recommendations? Am I required to use an access token set up? Because I couldn't find good documentation on how to do this. Perhaps the relevant google documentation, because I can't distinguish which is for unique web addresses and which is @gmail.com-specific.

1

There are 1 best solutions below

0
On BEST ANSWER

You typed in auth: 'OAuth2' instead of type: 'OAuth2'