Directus icon

Directus

Consume Directus API

Overview

This node integrates with the Directus API to manage users and their two-factor authentication (2FA) settings. Specifically, the "Enable 2FA" operation allows enabling two-factor authentication for the current user by providing a TFA secret and a one-time password (OTP) generated from that secret.

Use cases include enhancing account security by requiring an additional verification step during login. For example, after generating a TFA secret via the Directus API, you can use this node to enable 2FA by verifying the OTP generated by an authenticator app like Google Authenticator or Authy.

Properties

Name Meaning
Secret The TFA secret string obtained from a prior TFA generation step. It is required to enable 2FA.
OTP The one-time password generated using the secret, used to verify correct TFA setup. Required.

Output

The node outputs a JSON object representing the response from the Directus API after attempting to enable 2FA. This typically includes confirmation of the 2FA status or any relevant metadata returned by the API.

No binary data output is involved in this operation.

Example output structure (simplified):

{
  "json": {
    "status": "success",
    "message": "Two-factor authentication enabled."
  }
}

(Note: Actual response fields depend on the Directus API's response.)

Dependencies

  • Requires connection to a Directus instance via its REST API.
  • Needs an API key credential configured in n8n for authenticating requests to Directus.
  • The node uses the Directus API endpoint users/me/tfa/enable with HTTP POST method.

Troubleshooting

  • Invalid OTP or Secret: If the provided OTP does not match the secret, the API will reject the request. Ensure the OTP is freshly generated from the exact secret and entered correctly.
  • Authentication Errors: If the API key credential is missing or invalid, the node will fail to authenticate. Verify the credential configuration.
  • Network Issues: Connectivity problems to the Directus server will cause request failures. Check network access and Directus server availability.
  • API Endpoint Changes: If the Directus API version changes, endpoints or required parameters might differ. Confirm compatibility with your Directus version.

Common error messages:

  • "Invalid OTP": The OTP code is incorrect or expired.
  • "Unauthorized": Authentication failed due to invalid credentials.
  • "Bad Request": Missing or malformed parameters; ensure both secret and otp are provided.

Links and References

Discussion