-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Labels
priority: p3Desirable enhancement or fix. May not be included in next release.Desirable enhancement or fix. May not be included in next release.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.
Description
I am using googleapis to send emails on behalf of my customers. It works fine for most customers but for one in particular, I get the following error :
Error: Precondition check failed.
at Gaxios._request (/home/nicolas/mi/node_modules/gaxios/build/src/gaxios.js:84:23)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async OAuth2Client.requestAsync (/home/nicolas/mi/node_modules/googleapis-common/node_modules/google-auth-library/build/src/auth/oauth2client.js:343:18)
at async Object.sendEmail (/home/nicolas/mi/src/utils/google_api.js:53:4)
at async Object.sendEmail (/home/nicolas/mi/src/utils/email_manager.js:264:3)
After a few searches on the web, I found out that this error is related to service accounts, but I am not using service accounts, I am authenticated with OAuth.
So what could it be ? Does it has to do with the type of Google account my customer owns ?
The code of my method for sending emails :
const { google } = require('googleapis');
async sendEmail(credentials, to, subject, message, options) {
const oauth = new google.auth.OAuth2(config.oauth_client_id, config.oauth_client_secret, `${webConfig.hostname}/mon-compte`);
// set the user credentials
oauth.setCredentials(credentials);
// build the email
const raw = buildEmail(to, subject, message, options);
// send the email
await google.gmail({ version: 'v1', auth: oauth }).users.messages.send({
userId: 'me',
resource: { raw }
});
}
Metadata
Metadata
Assignees
Labels
priority: p3Desirable enhancement or fix. May not be included in next release.Desirable enhancement or fix. May not be included in next release.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.