Search code examples
authenticationoauth-2.0oauthjwtgoogle-oauth

Is there a way to keep oauth2 token for infinite time?


I am trying to build an app for scheduling youtube content, here is how the app works=>

  1. user signs in through google (I get his oauth2 token with youtube scope added)
  2. uploads a video on my site and gives me a time to post it

my question is: the oauth2 token will expire after a few weeks, what if the user wants me to post the video after 3 months , but he does not want to login to my app. Is there a way I can keep the token alive?

I am just learning so please be humble, This is surely possible because companies like hootsuite, zoho are achieving exactly this ,but how?


Solution

  • You need to get refresh token and use it to obtain a new access token without user interaction. To get refresh token and exchange for a new access token, you need to implement them in your back-end for security reason.