Actions111
- Item Actions
- Webhook Actions
- Collection Actions
- File Actions
- Activity Actions
- Asset Actions
- Authentication Actions
- Extension Actions
- Field Actions
- Folder Actions
- Permission Actions
- Preset Actions
- Relation Actions
- Revision Actions
- Role Actions
- Setting Actions
- User Actions
- Utility Actions
Overview
This node performs an Authentication - Login operation, allowing users to authenticate against a Directus API. It is typically used to obtain an access token or session cookie by providing user credentials (email and password), with optional support for two-factor authentication (OTP). This node is useful in workflows where subsequent steps require authenticated access to protected resources or APIs.
Practical examples:
- Logging in to Directus to retrieve an access token for use in later API calls.
- Automating user authentication as part of a data synchronization workflow.
- Handling 2FA-enabled logins by supplying a one-time password.
Properties
| Name | Type | Meaning |
|---|---|---|
| JSON/RAW Parameters | Boolean | Whether to provide body parameters as raw JSON or via the UI fields. |
| Body Parameters | JSON | The request body as JSON or RAW, used when "JSON/RAW Parameters" is enabled. |
| Password | String | The user's password (hidden input), required unless using raw JSON parameters. |
| String | The user's email address, required unless using raw JSON parameters. | |
| Additional Fields | Collection | Optional extra fields: - Mode: Choose between receiving the token as a string ("JSON") or setting it as a cookie ("Cookie"). - OTP: One-time password for 2FA if enabled. |
Output
The output will contain the authentication result from Directus:
- If "Mode" is set to JSON, the output will include the access token and possibly other metadata in the
jsonfield. - If "Mode" is set to Cookie, the output will indicate that a session cookie has been set (the actual cookie handling is managed internally).
- If "Mode" is set to JSON, the output will include the access token and possibly other metadata in the
The structure of the
jsonoutput field typically includes:{ "data": { "access_token": "string", "expires": "timestamp", ... } }or may be empty if only a cookie is set.
Binary Data: This node does not output binary data.
Dependencies
- Directus API endpoint: The node must be configured to point to a valid Directus instance.
- No explicit API key is required for login, but valid user credentials are necessary.
- n8n environment should allow outbound HTTP requests to the Directus server.
Troubleshooting
- Invalid Credentials: If the email or password is incorrect, you may receive an authentication error such as
401 Unauthorized. Double-check your credentials. - Missing OTP: If 2FA is enabled and no OTP is provided, the login will fail. Supply the correct OTP in the "Additional Fields".
- Incorrect Parameter Mode: If "JSON/RAW Parameters" is enabled but the JSON body is malformed, the request will fail. Ensure valid JSON syntax.
- Mode Mismatch: If expecting a token but "Mode" is set to "Cookie", the output may not include the token directly.