Question

I have an application that needs to be able to refresh the oauth2.0 access token every 59 days through a cron job. I don't want to have the user perform the authenticate again on the front end, I just want this to happen on the backend using a cron. Is this even possible? The main problem with the cron is that to get another valid oauth2.0 access token there needs to be a redirect. Does this redirect send information back to the cron for execution?

Overall, at a high level I only want the user to grant permissions once for my app to get a valid oauth2.0 access token. I will store this in my database and after 59 days and I will execute a cron job to retrieve another one (without the user ever having to do anything). Therefore the app works seamlessly and the user will never have to be authenticated again.

Thanks,

Kyle

Was it helpful?

Solution

I don't think you need a cron job for this. Once you have the initial access token (you might also have a refresh token at that time) you can refresh that anytime, at the same time your app initiates a connection to the external service. So right before you attempt to read or write data from the external service, refresh the token first, then proceed with the API requests.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top