Complete Guide to Setting Up and Generating TOTP Codes in n8n 🔐
Imagine This: Your Workflow Wants a Password Every 30 Seconds
You finally sit down with your coffee, ready to get things done, and what happens? Another login, another code, another “open authenticator app, copy code, paste code, repeat until your soul leaves your body” moment.
Now imagine your automations quietly handling those Time-based One-Time Passwords (TOTP) for you. No more copy-paste marathons, no more “where did I put my phone” panic. That is exactly what this n8n TOTP workflow template helps you do.
In this guide, you will learn how to generate TOTP codes inside n8n using the TOTP node, how to hook it into your workflows, and how to keep everything secure and in sync. Same strong security, far fewer sighs.
Quick Refresher: What Is TOTP, Really?
TOTP stands for Time-based One-Time Password. It is a short-lived passcode that is generated using:
- The current time
- A secret key that both the client and server know
The result is a code that usually changes every 30 seconds and can be used as a second factor in authentication. So even if someone gets your password, they still need that tiny, fast-expiring code to get in.
That is why TOTP is a core building block for two-factor authentication (2FA) and why it is so handy to generate it directly inside your n8n automations.
Why Use TOTP in n8n Workflows?
n8n is all about automating the boring stuff, and “typing codes again and again” definitely qualifies as boring. With the TOTP node, n8n can generate valid authentication codes on its own, in sync with your authentication server.
Here is what the TOTP node brings to your automation life:
- Automatic TOTP generation using a stored secret key
- Fresh codes every 30 seconds that match what your authenticator app would show
- Easy integration into any workflow that needs 2FA or temporary codes
So instead of you juggling codes in real time, your workflow can quietly fetch the TOTP and pass it along where needed.
Where This Actually Helps in Real Life
Once you have TOTP inside n8n, you can use it in all sorts of security-sensitive automations, for example:
- Automated login flows that require 2FA codes
- Secure API authentication where an extra TOTP step is needed
- CI/CD pipeline verification, for example when a deployment step needs a one-time code
Anywhere you would normally grab your phone to read a TOTP code, your workflow can do the job instead.
How the n8n TOTP Template Works (High-Level)
The template uses a simple combination of nodes:
- A Manual Trigger node so you can test things whenever you like
- The TOTP node, which uses stored credentials to generate the current TOTP code
You click “Test workflow”, n8n runs the TOTP node, and you instantly get a fresh code generated from your secret key. From there, you can plug that code into any other part of your automation.
Step-by-Step: Setting Up TOTP in n8n
Let us walk through the setup. It is short, painless, and involves zero copy-pasting from your phone.
1. Start With a Manual Trigger
First, add a Manual Trigger node to your workflow. This node is perfect for testing because you can run the workflow on demand by clicking “Test workflow” in the n8n editor.
2. Add the TOTP Node
Next, drag the TOTP node into your workflow and connect it to the Manual Trigger node.
This node is where the TOTP magic happens. It will generate a time-based one-time password every time the workflow runs.
3. Set Up TOTP Credentials
Inside the TOTP node, find the credentials section. Here you will:
- Select an existing TOTP account credential, or
- Create a new TOTP credential and store your secret key
This secret key is the same one that would normally be used in an authenticator app. n8n uses it to generate the exact same codes that app would show.
4. Configure Node Parameters
Good news, this part is usually light on effort. The TOTP node often needs only minimal configuration. Just make sure that:
- The secret key is correct
- The settings match your authentication server requirements, such as the time step (often 30 seconds)
Once those are aligned, n8n will produce valid TOTP codes in sync with your server.
5. Test Your Workflow
Now for the fun part. Click “Test workflow” in n8n.
The workflow runs, the TOTP node generates a fresh code, and you can see the output directly in the execution data. That code can then be used wherever your automation needs it, such as in a login step or API call.
Security & Reliability Tips for TOTP in n8n
Automating TOTP is powerful, but with great power comes the responsibility to not leave your secret keys lying around like sticky notes on a monitor.
1. Protect Your Secret Keys
Always store your TOTP secret keys securely. Do not expose them in logs, screenshots, or public repositories.
Use n8n credentials to keep the secret key safe inside your workflow configuration instead of hardcoding it in nodes or expressions.
2. Keep Clocks in Sync
TOTP is all about time. If your server time and n8n time do not agree, your codes will not either.
- Ensure your server clock is accurate
- Confirm that the client or authentication service also uses the correct time
A tiny time drift can mean a lot of “invalid code” messages, which is not the kind of automation excitement anyone wants.
3. Maintain Your Workflows
Security is not a “set it and forget it” thing. Make a habit of:
- Reviewing your workflows periodically
- Updating them if your security policies change
- Adapting to any new requirements from your authentication provider
This keeps your TOTP setup reliable and aligned with best practices over time.
Wrapping Up: Less Repetition, More Security
With the n8n TOTP node, you can bring strong two-factor authentication into your workflows without constantly playing “find the code” on your phone.
By using a Manual Trigger for testing, connecting the TOTP node, storing your secret key in credentials, and aligning settings with your authentication server, you get a secure, fully automated way to generate TOTP codes on demand.
Ready to stop typing the same codes over and over? Set up TOTP in n8n, plug it into your automations, and enjoy the peace of mind that comes with robust, hands-off authentication.
