Best way to have a Refresh/Access Token workflow?

I have some integrations with CRM, e-commerce, and other systems that use tokens for access that expire and also have a refresh feature. However, the way it was structured by the team is that every request calls for a token to be generated, which may result in an error indicating that the token already exists or generate a new one. The problem with this flow is that if it gives an error, I have to put “Continue” in the Workflow so as not to interrupt my flow, and I don’t like that idea at all.

I’m trying to think of some adaptation by creating tables in the database with functions, or triggers in N8N to perform this generation, or some other viable option for this solution and make it as performative as possible, following best practices and not making unnecessary requests.

Hi @FMagal

If you don’t have strict rate limits and your workflow doesn’t make too many requests, I’d suggest not storing the token at all,
Instead, you can simply request a new token whenever it’s needed by calling a subworkflow..

This keeps things simpler and avoids the complexity of managing token storage or refresh logic unless performance becomes an issue.