Need quick fix in a zapier custom integration

Job ID: 37645255

Budget: ₹600 – ₹1,500 INR

Hi,
I need help with custom zapier app that is built in developer.zapier.com. Task is to fix a already implemented oauth 2.0 authentication in app. Right now my app gets a oauth2.0 cred from a third app, In this access token is valid for a day and refresh token for a year. But issue is if a user connects then the auth expires in a day and next day reconnection is required, which is a troublesome task.
I want someone to help me figure out a way on how I can refresh the auth using refresh token once the auth expires. Here is the code that I am using to ensure that auth refresh after 401 error, but it is not working-
if (response.status === 401) throw new z.errors.RefreshAuthError();
when the error is invoked it is not updating the bundle creds. And in next invoke of refrshAuthError old bundle data leads to refresh token invalid response from api end point.
But at the same time I want the step to re-run after error.
Let me know you can figure this task.
Note:- I want to know how I can implement a solution, I may not be showing you current app.
Thanks
Related categories: API Zapier