Directus icon

Directus

Consume Directus API

Overview

This node integrates with the Directus API, specifically handling authentication-related operations such as user login. The "Login" operation under the "Authentication" resource allows users to authenticate by providing their email and password, optionally including a one-time password (OTP) for two-factor authentication (2FA). It supports sending parameters either as individual fields or as raw JSON.

Common scenarios where this node is beneficial include:

  • Automating user login workflows in Directus.
  • Integrating Directus authentication into broader automation pipelines.
  • Handling 2FA-enabled accounts by passing OTP codes during login.

Practical example:

  • A workflow that logs in a user to Directus using their email and password, retrieves an access token, and then uses that token to perform further API calls securely.

Properties

Name Meaning
Email The email address of the user to authenticate.
Password The password of the user.
JSON/RAW Parameters Boolean flag to choose between entering parameters as separate fields or as raw JSON input.
Body Parameters When JSON/RAW Parameters is enabled, this field accepts the body parameters as JSON or raw text.
Additional Fields Optional extra fields:
- Mode Choose how the token is retrieved: as a cookie or as JSON response.
- OTP One-time password for 2FA if enabled on the user account.

Output

The output is a JSON object containing the response from the Directus API after attempting to log in. This typically includes authentication tokens or session information depending on the mode selected.

If the mode is set to "cookie," the token may be set as a cookie in the response; if "json," the token is returned as part of the JSON response.

No binary data output is involved in this operation.

Dependencies

  • Requires an API key credential configured for Directus API access.
  • The node makes HTTP POST requests to the Directus /auth/login endpoint.
  • Proper network connectivity to the Directus instance is necessary.

Troubleshooting

  • Invalid credentials error: Occurs if the email or password is incorrect. Verify the credentials are correct.
  • Missing OTP error: If 2FA is enabled but no OTP is provided, login will fail. Provide the correct OTP in the additional fields.
  • Malformed JSON: When using JSON/RAW parameters, ensure the JSON syntax is valid to avoid parsing errors.
  • API connection issues: Check the API URL and credentials configuration if the node cannot reach the Directus server.
  • Unexpected response format: Ensure the "Mode" property matches your expected token retrieval method (cookie vs JSON).

Links and References


This summary focuses exclusively on the "Authentication" resource and "Login" operation as requested.

Discussion