{"record":{"id":"0f0dc17718c8acd6","repo":"n8n-io/n8n","slug":"invalid-authentication-token","errorCode":null,"errorMessage":"Invalid authentication token","messagePattern":"Invalid authentication token","errorType":"exception","errorClass":"ChatTriggerAuthorizationError","httpStatus":401,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/trigger/ChatTrigger/GenericFunctions.ts","lineNumber":59,"sourceCode":"\t\t\tfunction getCookie(name: string) {\n\t\t\t\tconst value = `; ${headers.cookie}`;\n\t\t\t\tconst parts = value.split(`; ${name}=`);\n\n\t\t\t\tif (parts.length === 2) {\n\t\t\t\t\treturn parts.pop()?.split(';').shift();\n\t\t\t\t}\n\t\t\t\treturn '';\n\t\t\t}\n\n\t\t\tconst authCookie = getCookie('n8n-auth');\n\t\t\tif (!authCookie) {\n\t\t\t\tthrow new ChatTriggerAuthorizationError(401, 'User not authenticated!');\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tawait context.validateCookieAuth(authCookie);\n\t\t\t} catch {\n\t\t\t\tthrow new ChatTriggerAuthorizationError(401, 'Invalid authentication token');\n\t\t\t}\n\t\t}\n\t}\n\n\treturn;\n}\n","sourceCodeStart":41,"sourceCodeEnd":66,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/trigger/ChatTrigger/GenericFunctions.ts#L41-L66","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await context.validateCookieAuth(authCookie);\n} catch {\n  // prompt the user to re-authenticate; do not retry with the same cookie\n  throw new ChatTriggerAuthorizationError(401, 'Invalid authentication token');\n}","preventionTips":["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."],"tags":["authentication","session","cookie","chat-trigger","token-expiry"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}