I have setup no-reply@domain.com
as an email group in my Gsuite Admin Panel. Now I want to send an email using that email address in node js for which I am using nodemailer. To achieve that I created service account in Google Cloud and add no-reply@domain.com
group as an owner. Problem is when I am using those generated credentials in my node app it throws me an error unauthorized_client
.
I have added client_id and required GMAIL scope in API permission in Gsuite. Only user accounts are working with service accounts and not group email.
Here is my sample nodemailer code
const smtpTransport = nodemailer.createTransport({
host: 'smtp.gmail.com',
port: 465,
secure: true,
auth: {
type: "OAuth2",
user: "no-reply@domain.com",
serviceClient: "109120716xxxxxxxxxxxxxx",
privateKey: "",
}
});
I am following this tutorial to achieve this https://medium.com/@imre_7961/nodemailer-with-g-suite-oauth2-4c86049f778a