{"record":{"id":"7d46859ea83a8077","repo":"n8n-io/n8n","slug":"user-not-authenticated","errorCode":null,"errorMessage":"User not authenticated!","messagePattern":"User not authenticated!","errorType":"exception","errorClass":"ChatTriggerAuthorizationError","httpStatus":401,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/trigger/ChatTrigger/GenericFunctions.ts","lineNumber":53,"sourceCode":"\t\t\tthrow new ChatTriggerAuthorizationError(403);\n\t\t}\n\t} else if (authentication === 'n8nUserAuth') {\n\t\tconst webhookName = context.getWebhookName();\n\n\t\tif (webhookName !== 'setup') {\n\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":35,"sourceCodeEnd":66,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/trigger/ChatTrigger/GenericFunctions.ts#L35-L66","documentation":"The Chat Trigger is configured for 'n8n User Auth' and this is not the setup webhook, but the incoming request carries no 'n8n-auth' cookie. The node requires the caller to be logged into n8n (the cookie is the n8n session token).","triggerScenarios":"authentication === 'n8nUserAuth', getWebhookName() !== 'setup', and getCookie('n8n-auth') from headers.cookie returns an empty/falsy value.","commonSituations":"Opening the chat URL in an incognito/private window or a different browser where the user is not logged into n8n; the session cookie expired; the chat is loaded in an iframe on a different origin that does not send the cookie; third-party cookie blocking.","solutions":["Log into the n8n instance in the same browser session before opening the chat URL.","Ensure the chat widget is served from the same origin as n8n so the n8n-auth cookie is sent.","If cookies are blocked, relax third-party cookie rules for the n8n origin or embed the chat within the authenticated n8n UI."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Browser-side: only open the chat URL after confirming an n8n-auth cookie exists.\nif (!document.cookie.split('; ').some(c => c.startsWith('n8n-auth='))) {\n  window.location.href = '/signin'; // redirect to n8n login\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Embed the chat inside the authenticated n8n UI rather than on a third-party origin.","Instruct users to log into n8n in the same browser before opening the chat URL.","Avoid incognito/private mode for n8n-user-auth chat sessions."],"tags":["authentication","session","cookie","chat-trigger","webhook"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}