Directus (DrWade) icon

Directus (DrWade)

Consume Directus API

Users → Generate 2FA

AI-generated

Overview

The Directus (DrWade) n8n node for the resource Users and operation Generate 2FA allows you to generate a Two-Factor Authentication (2FA) secret for the currently authenticated user in your Directus instance. This is typically used as part of enabling 2FA on a user's account, adding an extra layer of security.

Common scenarios:

  • Enabling 2FA for users in automated onboarding workflows.
  • Integrating Directus user security features into custom business processes.
  • Automating the setup of 2FA for administrative or high-privilege accounts.

Practical example:
You might use this node in a workflow that, after creating a new user or upon request, generates a 2FA secret so the user can scan it with an authenticator app.


Properties

Name Type Meaning
Password String The password of the currently authenticated user. Required to authorize 2FA generation.

Output

The output will be a JSON object containing the result of the 2FA generation request. While the exact structure depends on the Directus API response, it typically includes:

{
  "secret": "base32encodedsecret",
  "otpauth_url": "otpauth://totp/...",
  // ...other fields as provided by Directus
}
  • secret: The generated 2FA secret key (to be added to an authenticator app).
  • otpauth_url: A URL that can be converted into a QR code for easy scanning by authenticator apps.

If there is an error, the output will contain an error field with the error message.


Dependencies

  • Directus API: You must have access to a running Directus instance.
  • API Credentials: The node requires valid Directus API credentials configured in n8n under the name directusApi.
  • User Permissions: The authenticated user must have permission to manage their own 2FA settings.

Troubleshooting

Common issues:

  • Invalid Password: If the provided password is incorrect, the API will reject the request.
  • Insufficient Permissions: If the user does not have rights to enable 2FA, the operation will fail.
  • API Connectivity: Network or authentication errors may prevent communication with the Directus API.

Error messages and resolutions:

  • "Invalid credentials": Double-check the password and ensure the correct user is authenticated.
  • "Permission denied": Verify the user's role and permissions in Directus.
  • "Network error": Ensure the Directus instance is reachable from the n8n server.

Links and References

Discussion