Refresh Token oauth2

Hi,

I would like to integrate to 3rd. party services use oAuth and Open Id.

I can integrate with the service (using fetch and http api’s).
Once oauth is establish I save the AccessToken in dataset and use it until it expires.

My question is: is there a way I can run background task to refresh to token?

If not - Is there a workaround?

Thank you

did you find a workaround for this?
Thanks

Intercept the dataset currentItem() on dataset.onReady() fucntion. If the token has expired then renew/update the collection.
Normally, the OAuth2 is used on backend to keep the key/secret/token safe.

I just got back to this feature.
Will inform you once development is done (few days I believe)

1 Like

Thanks. I was planning to implement on the backend for security. Seems like there is no “cron job” like timer that can run on the server and renew the refresh token before it expires.

Organic use of the site could be used to periodically call a backend function to check on the tokens for refresh.

Another idea is to use a non-Wix server or service along with a webhook on Wix. That way one could use, say, an actual cron job every 29 days (or whatever the expiration period is) to call the hook on Wix and trigger a refresh, if needed.

Of course, Wix webhooks run off OAuth and tokens too, so this kicks the issue down the road a bit!

Try https://cron-job.org/en/ and set a POST api to fire the renew.
Unless the expiration cancels anything, you can renew it when the token will be used.
Store the token and the expiration date on collection. When the user order the token, check expiration date to renew and send it back.

Hold on … what’s this?
Velo: Scheduling Recurring Jobs | Help Center | Wix.com

There is a cron job scheduler?

Yes it is. I read on wix release notes but I could not remember.

Hi Roi, what grant_type did you use?