What This Workflow Does
This n8n workflow automates the generation of Time-based One-Time Password (TOTP) codes used for two-factor authentication. It eliminates the need for manual code entry from authenticator apps, enabling secure automation of processes that require 2FA.
The template handles the entire TOTP lifecycle - from extracting secrets from QR codes to generating valid authentication codes on demand. It's particularly valuable for IT teams managing automated systems that require secure logins without human intervention.
How It Works
Step 1: QR Code Processing
The workflow begins by processing the QR code received when enabling two-factor authentication. It extracts the secret key and account information embedded in the QR code URL.
Step 2: Secret Key Storage
The extracted TOTP secret is securely stored in n8n's credential system. This encrypted storage ensures the sensitive authentication material remains protected while being accessible to the workflow.
Step 3: Code Generation
Using the stored secret and current timestamp, the workflow generates valid TOTP codes according to the RFC 6238 standard. These codes refresh automatically based on the time interval specified.
Step 4: Code Utilization
The generated codes can be used directly in subsequent workflow steps for authentication purposes, or output for use in other systems requiring two-factor verification.
Pro tip: Combine this with n8n's error handling nodes to automatically retry authentication if a code expires during processing.
Who This Is For
This workflow is ideal for:
- IT teams managing automated system logins
- DevOps engineers needing CI/CD pipeline authentication
- Security teams implementing automated monitoring
- Businesses with multiple accounts requiring scheduled 2FA
What You'll Need
- An active n8n instance (cloud or self-hosted)
- The QR code or secret key from your 2FA setup
- Basic familiarity with n8n workflows
- Permissions to create and store credentials in n8n
Quick Setup Guide
- Download and import the JSON workflow file into your n8n instance
- Configure the credential node with your TOTP secret
- Test the workflow with a sample QR code or secret
- Connect the output to your authentication process
- Schedule or trigger the workflow as needed
Key Benefits
Save 10+ hours monthly by eliminating manual TOTP code entry for automated processes. No more interrupting workflows to input 2FA codes.
Reduce authentication errors with automated code generation that's always synchronized with the correct time window.
Enable secure automation of processes that previously required human intervention due to 2FA requirements.
Centralize TOTP management for multiple accounts and services in one secure location.