mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
feat(HTTP Request Node): New http request generic custom auth credential (#5798)
This commit is contained in:
@@ -8,6 +8,7 @@ import type {
|
||||
INodeType,
|
||||
INodeTypeBaseDescription,
|
||||
INodeTypeDescription,
|
||||
IRequestOptionsSimplified,
|
||||
JsonObject,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
@@ -969,6 +970,7 @@ export class HttpRequestV3 implements INodeType {
|
||||
let httpDigestAuth;
|
||||
let httpHeaderAuth;
|
||||
let httpQueryAuth;
|
||||
let httpCustomAuth;
|
||||
let oAuth1Api;
|
||||
let oAuth2Api;
|
||||
let nodeCredentialType;
|
||||
@@ -992,6 +994,10 @@ export class HttpRequestV3 implements INodeType {
|
||||
try {
|
||||
httpQueryAuth = await this.getCredentials('httpQueryAuth');
|
||||
} catch {}
|
||||
} else if (genericAuthType === 'httpCustomAuth') {
|
||||
try {
|
||||
httpCustomAuth = await this.getCredentials('httpCustomAuth');
|
||||
} catch {}
|
||||
} else if (genericAuthType === 'oAuth1Api') {
|
||||
try {
|
||||
oAuth1Api = await this.getCredentials('oAuth1Api');
|
||||
@@ -1345,6 +1351,24 @@ export class HttpRequestV3 implements INodeType {
|
||||
};
|
||||
authDataKeys.auth = ['pass'];
|
||||
}
|
||||
if (httpCustomAuth !== undefined) {
|
||||
const customAuth = jsonParse<IRequestOptionsSimplified>(
|
||||
(httpCustomAuth.json as string) || '{}',
|
||||
{ errorMessage: 'Invalid Custom Auth JSON' },
|
||||
);
|
||||
if (customAuth.headers) {
|
||||
requestOptions.headers = { ...requestOptions.headers, ...customAuth.headers };
|
||||
authDataKeys.headers = Object.keys(customAuth.headers);
|
||||
}
|
||||
if (customAuth.body) {
|
||||
requestOptions.body = { ...requestOptions.body, ...customAuth.body };
|
||||
authDataKeys.body = Object.keys(customAuth.body);
|
||||
}
|
||||
if (customAuth.qs) {
|
||||
requestOptions.qs = { ...requestOptions.qs, ...customAuth.qs };
|
||||
authDataKeys.qs = Object.keys(customAuth.qs);
|
||||
}
|
||||
}
|
||||
|
||||
if (requestOptions.headers!.accept === undefined) {
|
||||
if (responseFormat === 'json') {
|
||||
|
||||
Reference in New Issue
Block a user