{"record":{"id":"b3b0456aceb570d9","repo":"n8n-io/n8n","slug":"missing-gateway-token-in-deeplink-connect-from-n8","errorCode":null,"errorMessage":"Missing gateway token in deeplink. Connect from n8n using the computer-use link.","messagePattern":"Missing gateway token in deeplink\\. Connect from n8n using the computer-use link\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/@n8n/local-gateway/src/main/index.ts","lineNumber":56,"sourceCode":"\n\t\t\tapp.setAsDefaultProtocolClient(DEEP_LINK_PROTOCOL);\n\n\t\t\tconst settingsStore = new SettingsStore();\n\t\t\tconfigure({ level: settingsStore.get().logLevel });\n\t\t\tlogger.info('n8n Gateway starting');\n\n\t\t\tconst controller = new DaemonController();\n\n\t\t\tconst preloadPath = path.join(__dirname, 'preload.js');\n\t\t\tconst rendererPath = path.join(__dirname, '..', 'renderer', 'index.html');\n\n\t\t\tasync function connect(payload: ConnectPayload): Promise<void> {\n\t\t\t\tconst settings = settingsStore.get();\n\t\t\t\tassertConnectOriginAllowed(payload.url, settings.allowedOrigins);\n\t\t\t\tconst config = settingsStore.toGatewayConfig(settings);\n\t\t\t\tconst token = payload.apiKey?.trim();\n\t\t\t\tif (!token || token.length === 0) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t'Missing gateway token in deeplink. Connect from n8n using the computer-use link.',\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tawait controller.connect(config, payload.url, token);\n\t\t\t}\n\n\t\t\tasync function disconnectGateway(): Promise<void> {\n\t\t\t\tawait controller.disconnect();\n\t\t\t}\n\n\t\t\tfunction handleConnectPayload(payload: ConnectPayload): void {\n\t\t\t\tlogger.info('Handling deep-link connection payload', { url: payload.url });\n\t\t\t\tvoid connect(payload).catch((error: unknown) => {\n\t\t\t\t\tlogger.error('Deep-link connection failed', {\n\t\t\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t\t\t});\n\t\t\t\t\topenSettingsWindow(preloadPath, rendererPath);\n\t\t\t\t});","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/local-gateway/src/main/index.ts#L38-L74","documentation":"Thrown by the gateway connect handler when the deep-link payload's apiKey, after trim(), is empty. The deep link is expected to carry a gateway token (apiKey) issued by the trusted n8n instance; without it the gateway cannot authenticate to the instance. This fires after assertConnectOriginAllowed passes, before DaemonController.connect is called.","triggerScenarios":"Handling a connect deep-link payload (handleConnectPayload → connect) where payload.apiKey is undefined, empty, or only whitespace. The deep link was constructed without the token parameter, or the token was stripped.","commonSituations":"User opened a stale deep link from before the token was issued; the deep link was copy-pasted and the token query parameter got truncated; the n8n instance generated the deep link without embedding the API key; the deep-link URL was manually constructed without the token.","solutions":["Generate a fresh computer-use deep link from the trusted n8n instance (it embeds the token).","Do not hand-edit the deep link — copy it whole from n8n.","Confirm the n8n instance has a valid gateway API key configured before generating the link.","Reconnect from n8n rather than pasting a URL into the gateway."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function hasGatewayToken(payload: { apiKey?: string }): boolean {\n  const t = payload.apiKey?.trim();\n  return !!t && t.length > 0;\n}","typeGuard":"function isConnectPayloadWithToken(payload: unknown): payload is { apiKey: string; url: string } {\n  return typeof payload === 'object' && payload !== null\n    && 'apiKey' in payload && typeof (payload as any).apiKey === 'string'\n    && (payload as any).apiKey.trim().length > 0;\n}","tryCatchPattern":null,"preventionTips":["Always generate the deep link from the trusted n8n instance so the token is embedded.","Do not hand-edit deep links — copy them whole.","Validate payload.apiKey presence before calling connect()."],"tags":["local-gateway","authentication","deeplink","token"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}