Skip to content
Back

Appwrite OAuth2 RefreshToken Logic

  • 1
  • Auth
  • Web
Bald
25 Jun, 2025, 06:27

For some context, I'm a beginner that is trying to figure out how to work with appwrite and oauth2 and I'd appreciate any help I can get. I'm currently trying to create a backend function that I could later schedule with Cron that can automate certain things. However, to do this, I believe I need to get the user's refreshToken and store it in the database, as appwrite currently only allows you to refresh your access token when the user is signed into the app, and not while a scheduled function is occurring. The current issue I have is that google is giving me a blank string for the providerRefreshToken whenever I try and go through the OAuth process. I've tried resetting permissions to the website on my google account and also trying fresh google accounts that've never interacted with my code before, yet it still never gives me a refresh token that I can store. The following is my main ui code (just a simple login with google + display name). After a user logs in, I've made a function that takes that signup alert and simply prints the google response, yet the refreshToken is always blank. Attached is my main ui code.

TL;DR
Developers trying to automate tasks with Appwrite and OAuth2 are struggling to retrieve and store the user's refreshToken in the database for scheduled functions. Despite attempting to reset permissions and use new Google accounts, the providerRefreshToken is consistently empty. This issue arises when trying to refresh the access token without the user being actively signed into the app.
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