Back

Update OAuth session (refresh tokens)

  • 0
  • Web
Eilon
20 Feb, 2024, 09:31

In the Appwrite docs it says: (https://appwrite.io/docs/products/auth/oauth2) OAuth 2 sessions expire to protect from security risks. OAuth 2 sessions should be refreshed periodically, so access tokens don't expire. **Check value of providerAccessTokenExpiry to know if the token is expired or is about to expire. Refreshing before every request might cause rate limit problems. You can do this by calling the Update OAuth Session endpoint when ever your user visits your app. ** I'm using Nextjs btw. const promise = account.updateSession('[SESSION_ID]'); Where should I call updateSession ? Can you please explain how to do it, is there any code example ? Thank you :appwriteheart:

TL;DR
- Developers should periodically refresh OAuth 2 sessions to prevent expiration of access tokens. - To do this, call the `updateSession` method whenever a user visits the app. - This helps avoid rate limit issues that might arise from refreshing before every request. - The specific implementation might vary, but in Next.js, you can include `const promise = account.updateSession('[SESSION_ID]');` where needed in your code.
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