Skip to content
Back

OAuth “invalid_grant” Error in Appwrite Cloud Function

  • 0
  • Cloud
dayo
9 Mar, 2025, 02:41

Hey @Support , I’m running a serverless function in Appwrite Cloud that sends emails using Google OAuth (nodemailer + googleapis). The same code works perfectly when tested locally, but in Appwrite Cloud, I keep getting this error: Error sending email: Error: invalid_grant I’ve already checked: My client_id, client_secret, and refresh_token are correct. The refresh token is working locally. The Appwrite function’s environment variables are set correctly. The function is running in the latest Node.js runtime.

TL;DR
Developers are encountering an "invalid_grant" error when attempting to send emails using Google OAuth in an Appwrite Cloud Function, despite the code working fine locally. They have verified the correctness of client_id, client_secret, and refresh_token, along with environment variables. The issue could arise from the server's time being out of sync or the refresh token being revoked by Google. To resolve this, developers should ensure the server time is accurate or generate a new refresh token.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more