Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error "Precondition check failed" #506

Open
Cooya opened this issue Apr 18, 2023 · 1 comment
Open

Error "Precondition check failed" #506

Cooya opened this issue Apr 18, 2023 · 1 comment
Assignees
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: question Request for information or clarification. Not an issue.

Comments

@Cooya
Copy link

Cooya commented Apr 18, 2023

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 }
   });
}
@Cooya Cooya added priority: p3 Desirable enhancement or fix. May not be included in next release. type: question Request for information or clarification. Not an issue. labels Apr 18, 2023
@Cooya
Copy link
Author

Cooya commented Jul 5, 2023

Is anyone there ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

2 participants