n8n-io/n8n · error · NodeOperationError
Invalid authentication method
Error message
Invalid authentication method
What it means
The default branch of a switch on authenticationMethod in the Azure OpenAI Chat node. The switch only handles AuthenticationType.ApiKey and AuthenticationType.EntraOAuth2; any other value (or an unknown future auth type) hits the default and throws NodeOperationError before the client is built.
Source
Thrown at packages/@n8n/nodes-langchain/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.ts:98
itemIndex,
) as AuthenticationType;
const modelName = this.getNodeParameter('model', itemIndex) as string;
const options = this.getNodeParameter('options', itemIndex, {}) as AzureOpenAIOptions;
// Set up Authentication based on selection and get configuration
let modelConfig: AzureOpenAIApiKeyModelConfig | AzureOpenAIOAuth2ModelConfig;
switch (authenticationMethod) {
case AuthenticationType.ApiKey:
modelConfig = await setupApiKeyAuthentication.call(this, 'azureOpenAiApi');
break;
case AuthenticationType.EntraOAuth2:
modelConfig = await setupOAuth2Authentication.call(
this,
'azureEntraCognitiveServicesOAuth2Api',
);
break;
default:
throw new NodeOperationError(this.getNode(), 'Invalid authentication method');
}
this.logger.info(`Instantiating AzureChatOpenAI model with deployment: ${modelName}`);
const timeout = options.timeout;
const model = new AzureChatOpenAI({
// Force completions API — Azure's SDK doesn't rewrite the /responses path,
// so the Responses API hits an invalid endpoint and causes a connection error.
// See: https://github.com/langchain-ai/langchainjs/issues/9038
useResponsesApi: false,
// Model name is required so logs are correct
// Also ensures internal logic (like mapping "maxTokens" to "maxCompletionTokens") is correct
model: modelName,
azureOpenAIApiDeploymentName: modelName,
...modelConfig,
...options,
timeout,
maxRetries: options.maxRetries ?? 2,View on GitHub (pinned to 5ac6606e81)
Solutions
- Open the node credential selector and re-pick 'API Key' or 'Entra ID (OAuth2)'.
- Recreate the credential if the dropdown does not show a valid selection.
- Upgrade n8n / nodes-langchain so the auth type enum matches the code's switch arms.
Example fix
// before authenticationMethod === 'azureActiveDirectory' // no longer handled // after authenticationMethod === 'entraOAuth2'
Defensive patterns
Strategy: type-guard
Validate before calling
const ALLOWED = [AuthenticationType.ApiKey, AuthenticationType.EntraOAuth2];
if (!ALLOWED.includes(authenticationMethod)) {
throw new Error(`Pick 'API Key' or 'Entra ID (OAuth2)' in the credential selector.`);
} Type guard
const isSupportedAuth = (m: unknown): m is AuthenticationType => m === AuthenticationType.ApiKey || m === AuthenticationType.EntraOAuth2;
Try / catch
// Validate the enum at node-save time; surface allowed values.
Prevention
- Always use the dropdown for authentication method.
- Recreate the node/credential if importing a deprecated auth type.
- Upgrade nodes-langchain to keep the enum and switch arms aligned.
When it happens
Trigger: authenticationMethod parameter holds a value outside {apiKey, entraOAuth2} — e.g. from a hand-edited workflow JSON, a stale value from a deprecated auth type, or a forward-incompatible enum.
Common situations: Importing an older workflow that used a removed auth method; manually editing the workflow JSON; future n8n version adding a new auth type that the current code doesn't handle; corrupted credential parameter.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- The value in the "Extra Body" field is not valid JSON
- The value in the "Extra Body" field must be a JSON object
- Failed to initialize Azure OpenAI client: ${error.message}
- API Key is missing in the selected Azure OpenAI API credenti
- VectorStore "${this.name}" requires a description — set it v
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/07d33c8c7b7ef476.
Report an issue: GitHub.