I’m working with n8n and struggling to create an automated system for refreshing AWS Cognito OAuth tokens.
Right now I have to manually update the token each day which is really annoying. I want to build something that handles this automatically so I don’t have to keep doing it myself.
What I tried so far:
I created a workflow in n8n that calls the AWS Cognito token refresh endpoint. I thought this would automatically get new access tokens and update them in my workflow without me having to do anything.
The problem:
The workflow isn’t working like I expected. The token refresh doesn’t happen on its own and I still have to run it manually to get fresh access tokens.
What I need:
I’m looking for a solution that will automatically handle the token renewal process without me having to manually start the workflow each time. Has anyone figured out how to make this work properly in n8n?
It appears the challenge lies in n8n’s handling of credential updates. To automate AWS Cognito token renewal, consider implementing a scheduled workflow. Set up a cron trigger to run every 45-50 minutes to invoke the Cognito token refresh endpoint. This will help ensure that the tokens are updated before they expire. Additionally, modify your existing workflows to fetch the latest token from your storage mechanism, rather than relying on hardcoded values. Incorporating robust error handling and even a notification system can also be beneficial for catching any refresh issues early, thereby maintaining the integrity of your automation.
Yeah, n8n workflows don’t save credential updates between runs by default - ran into this headache with OAuth providers myself. You need a webhook endpoint that external systems can hit, or build a proper credential management flow. Make a workflow that refreshes tokens AND saves them to a database or external storage your other workflows can access. Then set up your main workflows to grab fresh credentials from that storage before each run instead of using n8n’s built-in system. Way more control over token lifecycle and no more manual fixes.