n8n-io/n8n · error · ChatTriggerAuthorizationError
Invalid authentication token
Error message
Invalid authentication token
What it means
The Chat Trigger uses 'n8n User Auth', an 'n8n-auth' cookie was present, but context.validateCookieAuth(authCookie) rejected it. The cookie exists but is invalid, expired, or was issued by a different n8n instance.
Source
Thrown at packages/@n8n/nodes-langchain/nodes/trigger/ChatTrigger/GenericFunctions.ts:59
function getCookie(name: string) {
const value = `; ${headers.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) {
return parts.pop()?.split(';').shift();
}
return '';
}
const authCookie = getCookie('n8n-auth');
if (!authCookie) {
throw new ChatTriggerAuthorizationError(401, 'User not authenticated!');
}
try {
await context.validateCookieAuth(authCookie);
} catch {
throw new ChatTriggerAuthorizationError(401, 'Invalid authentication token');
}
}
}
return;
}
View on GitHub (pinned to 5ac6606e81)
Solutions
- Log out of n8n and log back in to obtain a fresh n8n-auth cookie.
- Clear the n8n-auth cookie in the browser devtools and reload.
- If the n8n instance secret changed, restart affected browser sessions.
Defensive patterns
Strategy: try-catch
Try / catch
try {
await context.validateCookieAuth(authCookie);
} catch {
// prompt the user to re-authenticate; do not retry with the same cookie
throw new ChatTriggerAuthorizationError(401, 'Invalid authentication token');
} Prevention
- Treat a validateCookieAuth failure as a hard re-login, not a retry.
- Surface a clear 'session expired, please log in again' message to end users.
- Coordinate n8n session-secret rotations with forced re-login of chat users.
When it happens
Trigger: validateCookieAuth throws (e.g. signature mismatch, expired session, revoked token); the inner error is swallowed and a ChatTriggerAuthorizationError(401, 'Invalid authentication token') is thrown instead.
Common situations: Stale n8n-auth cookie left in the browser from an old login; cookie copied from another n8n instance; the n8n session secret was rotated invalidating existing cookies; the user was logged out server-side.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- User not authenticated!
- No authentication data defined on node!
- Authorization is required!
- Authorization data is wrong!
- Unauthorized
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/0f0dc17718c8acd6.
Report an issue: GitHub.