{"record":{"id":"0239248aac6de325","repo":"n8n-io/n8n","slug":"authorization-is-required","errorCode":null,"errorMessage":"Authorization is required!","messagePattern":"Authorization is required!","errorType":"exception","errorClass":"ChatTriggerAuthorizationError","httpStatus":401,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/trigger/ChatTrigger/GenericFunctions.ts","lineNumber":31,"sourceCode":"\tconst headers = context.getHeaderData();\n\n\tif (authentication === 'none') {\n\t\treturn;\n\t} else if (authentication === 'basicAuth') {\n\t\t// Basic authorization is needed to call webhook\n\t\tlet expectedAuth: ICredentialDataDecryptedObject | undefined;\n\t\ttry {\n\t\t\texpectedAuth = await context.getCredentials<ICredentialDataDecryptedObject>('httpBasicAuth');\n\t\t} catch {}\n\n\t\tif (expectedAuth === undefined || !expectedAuth.user || !expectedAuth.password) {\n\t\t\t// Data is not defined on node so can not authenticate\n\t\t\tthrow new ChatTriggerAuthorizationError(500, 'No authentication data defined on node!');\n\t\t}\n\n\t\tconst providedAuth = basicAuth(req);\n\t\t// Authorization data is missing\n\t\tif (!providedAuth) throw new ChatTriggerAuthorizationError(401);\n\n\t\tif (providedAuth.name !== expectedAuth.user || providedAuth.pass !== expectedAuth.password) {\n\t\t\t// Provided authentication data is wrong\n\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}","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/trigger/ChatTrigger/GenericFunctions.ts#L13-L49","documentation":"The Chat Trigger is configured for Basic Auth and the incoming webhook request has no HTTP 'Authorization' header. basicAuth(req) (from the 'basic-auth' library) returns undefined, so the node throws ChatTriggerAuthorizationError(401). This is a client-side error: the caller did not supply credentials.","triggerScenarios":"authentication === 'basicAuth', httpBasicAuth credential is valid, but basicAuth(req) returns a falsy value because the request lacks an 'Authorization: Basic <base64(user:pass)>' header.","commonSituations":"Calling the chat webhook URL via curl without -u, fetch/axios without an Authorization header, an embedded chat widget that strips headers, or a proxy/load-balancer removing the Authorization header before it reaches n8n.","solutions":["Send the request with a Basic Authorization header: Authorization: Basic <base64(user:password)>.","With curl: curl -u user:pass <webhook-url>.","If a reverse proxy sits in front of n8n, configure it to forward the Authorization header."],"exampleFix":"// before: fetch(webhookUrl, { method: 'POST', body })\n// after:  fetch(webhookUrl, { method: 'POST', body, headers: { Authorization: 'Basic ' + btoa('user:pass') } })","handlingStrategy":"validation","validationCode":"// Caller-side: build the Authorization header before sending.\nconst token = Buffer.from(`${user}:${pass}`, 'utf8').toString('base64');\nif (!user || !pass) throw new Error('user/pass required for Basic Auth');\nawait fetch(url, { headers: { Authorization: `Basic ${token}` } });","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include an Authorization header when calling a Basic-Auth-protected webhook.","In curl, use -u user:pass rather than constructing the header by hand.","Confirm reverse proxies forward the Authorization header to n8n."],"tags":["authentication","http","webhook","chat-trigger","client-error"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}