I need to create an integration for a customer with the Guesty.com API.
However, Guesty uses expiring access tokens. Which means you have to request a new acces token each 24h.
Yeah you can do that with a conditional (branching) action. Start by checking if the token is still valid. If is isn’t, make an API call to get a new token, wait until it arrives, and then make the second API call. If it isn’t, skip the token refresh and go ahead and make the call.
I guess you would have to create one API call to get the access code and store the acces code in the database?
And one any action that needs info from the API check if it’s less than 1h from the expiration date of the current access code, if yes, call the API to request a new acces code and continue to call the API with the old access code.
The next API call will have the new access code.
The only pitfall in this is that you will need to store the access token in a publicly available way in the database…
Yeah that’s a good point. Off the top of my head, the only way I can think around that is to delegate the API calls to something like Make, via a webhook.
I guess an alternative could be to request a new token with every execution, and then immediately clear it
Clearing it immediately doesn’t work as there will be a limit on token request calls. Mitigating to another tool would work! Thanks for the help man!
Maybe you can write the timestamp of when an access token is generated, and calculate their expiring time. When you make a call, if the expiring time is after now, proceed as usual, else generate a new token first before making the main call.