Hi! i currently have a system that automatically refreshes the users access token 10 minutes before it expires. BUT the user has to be active on the screen for it to happen!
I am looking for a way that i can handle this automatically in the backend, with no need of using the front end.
Can anybody help?
I have in the db the refresh token which i then use to torigger an api call to google for it to refresh the token.
I think you are not using API workflows to create the new token or to refresh the token.
You should create two API workflows.
GetToken
RefreshToken
GetToken should generate the token for the first time when the user connect the google account for the 1st time. Within the GetToken workflow, you should schedule RefreshToken to run after X mins (depends on the token expiry)
RefreshToken will use the refresh token you got from the 1st call to refresh the token and get a new access token. Once you get the new access token, update the db entry with new data (tokens and expiry). Within this workflow add another schedule workflow action to schedule itself (RefreshToken) after X mins. This will take care of subsequent run for the future.
Hi! i currently do the whole process manually, i start the 0auth flow with the user login in with google and retrieving an access code in the url parameter that then triggers to fecth an access token!
what i need it for that users access to be refreshed before it expires cause my app triggers api calls for google ads and the user won’t be active probably
@codefree out of interest do you find these ever failing? if so what do you do to mitigate this. the reason i ask is that i take this approach but its not consistent periodically the token is not refreshed.
@Bubbleboy I have been using this for years now, So far I haven’t faced any issue with this approach if the configuration is done correctly. This is strictly set up as per google’s official documentation for OAuth.
If you have any specific use case, I would be happy to deep dive with you and try to identify the root cause for the same.
I have this exact same set up! the thing is, how do i make it so it automatically refreshes the otken before it expires after 1 hour? wihtout the user being active in the site? cause my users create rules that trigger at another moment, probably after their tokens had epxired, but without being present in the site, it won’t refresh.
i had like if current time > -5 minutes token expiry, trigger that api call to refresh it. but that need the user to actually be in the site