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

"Precondition check failed" with gmail client + oauth2 #3532

Open
jamiedavenport opened this issue Aug 4, 2024 · 2 comments
Open

"Precondition check failed" with gmail client + oauth2 #3532

jamiedavenport opened this issue Aug 4, 2024 · 2 comments
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

@jamiedavenport
Copy link

I've setup Google OAuth with Lucia and storing the refresh token in the database.

I've tried to create a gmail client like so, using the stored refresh token:

export async function createGmailClient(refreshToken: string) {
  const auth = new google.auth.OAuth2(clientId, clientSecret, redirectUri);
  auth.setCredentials({ refresh_token: refreshToken });

  return google.gmail({ version: "v1", auth });
}

And then listing messages like so:

const messages = await client.users.messages.list({
      userId: "me",
    });

But I'm getting a 400 - Precondition check failed. error which is strange to see since most reports talk about this error with service accounts.

I'm assuming that I've setup the OAuth2 client incorrectly but the error messages aren't very helpful. Any help here would be hugely appreciated.

@jamiedavenport jamiedavenport 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 Aug 4, 2024
@rnuyts
Copy link

rnuyts commented Aug 26, 2024

Hi @jamiedavenport,

We have the same issue with the Ruby Gmail Client and also using OAuth authentication.

When we try to send an email for one of our users, we have this "Precondition check failed" error. For the other users (using other Google Workspace accounts), it works perfectly.

And we don't know why it happens for this specific user...

@juslin03
Copy link

Anyone got this work ?

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

3 participants