Hi Everyone! I’m trying to setup a simple backend workflow which will automatically refresh a users access token whenever their current one expires.
I’ve successfully configured the API and workflows to get an access and refresh token and token expiry date/time and I add these to a user record. Now I’d like a backend workflow that triggers if a user is logged in and their access token expires it automatically refreshes their token but for some reason I can’t get it to trigger?
I’ve added some photos for you. Any advice on how to test backend workflows like this would be much appreciated!
I recommend to not use recurring event, but instead schedule API workflow when you need it to be refreshed. Let’s say a user doesn’t login anymore, you will keep spending WU for inactive user.
Also, this always depend on how long the access token is valid.
Thanks for the answers everyone. Is the attached a better solution? On my homepage when user is logged in and token expires it schedules a backend API workflow.
Should this only trigger from the homepage or every page? Is there a way to test these workflows to check I get the right data back and the trigger works?
Again, this depend on how long the access token is valid. According to doc, it seem to be short (like 30 min). So I guess you will need to check it more often. But you should check it before you need it, not when user log in.
For example, you have an action to update hubspot contact, check the token before this action. If expired, refresh it, if not, continue workflow.
Thanks @Jici so does this mean for every API call I want to make in my app I should check if their token has expired and if so then run this backend workflow before continuing with the rest of the workflow? Will I need to add this action to every API workflow in the App?
For this API, this is probably what I would choose. But check how much time the token expire (in the doc, HS show 1800sec, but this could be an example and not a real value).
But I don’t know what are your workflows and what your app is doing. And maybe this is not the better choice.