I’m working with n8n and trying to create an automatic system for refreshing AWS Cognito OAuth tokens. Right now I have to manually update the token each day which is really annoying.
I built a workflow that calls the AWS Cognito token refresh endpoint, thinking it would handle everything automatically. The idea was that the access token would get renewed on its own without me having to do anything.
But it’s not working like I hoped. The workflow runs but doesn’t actually refresh the token properly, so I still end up having to run it manually to get a fresh access token.
Does anyone know how to make this work so the token gets refreshed automatically without any manual steps? I must be missing something in my setup.
The workflow timing’s probably your issue. I hit this exact problem last year - n8n wasn’t saving the refreshed token between runs. Here’s what fixed it for me: First, build a separate workflow just for token refresh that writes back to the credential store using n8n’s internal API. Second, trigger based on token expiration instead of daily schedules. Also check if your refresh token’s still valid - AWS Cognito refresh tokens do expire. If yours died, the workflow looks like it’s working but won’t generate new access tokens. Add some logging to see when refreshes actually work vs just finish without errors.
Had the same problem a few months ago. The issue was token storage and timing. Your refresh workflow isn’t actually updating the stored credentials in n8n - it’s just grabbing a new token and doing nothing with it. You need to use the n8n API or database operations to write that new token back to your credential config. Also, schedule the refresh before your current token expires. I was cutting it too close and kept getting auth failures. Add proper error handling too - if the refresh fails silently, you won’t know until your main workflows break. Bottom line: make sure the refreshed token actually replaces the old one in your credentials store.
check your Cognito app client settings - some configs disable refresh tokens by default. also verify your workflow’s actually triggering when it should. i screwed mine up and it ran at wrong intervals, so tokens expired before the next refresh. add a webhook or manual trigger to test the refresh logic before automating it.