From 6453996de30e9635bda373f9f120a54621a8a69f Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Sun, 5 Dec 2021 17:00:41 +0100 Subject: [PATCH] :sparkles: Add support for Query Auth --- .../credentials/HttpQueryAuth.credentials.ts | 27 +++++++++++++++++++ .../nodes/HttpRequest/HttpRequest.node.ts | 22 +++++++++++++++ packages/nodes-base/package.json | 1 + 3 files changed, 50 insertions(+) create mode 100644 packages/nodes-base/credentials/HttpQueryAuth.credentials.ts diff --git a/packages/nodes-base/credentials/HttpQueryAuth.credentials.ts b/packages/nodes-base/credentials/HttpQueryAuth.credentials.ts new file mode 100644 index 0000000000000..79e4c1c6ca535 --- /dev/null +++ b/packages/nodes-base/credentials/HttpQueryAuth.credentials.ts @@ -0,0 +1,27 @@ +import { + ICredentialType, + INodeProperties, +} from 'n8n-workflow'; + + +export class HttpQueryAuth implements ICredentialType { + name = 'httpQueryAuth'; + displayName = 'Query Auth'; + documentationUrl = 'httpRequest'; + icon = 'node:n8n-nodes-base.httpRequest'; + properties: INodeProperties[] = [ + { + displayName: 'Name', + name: 'name', + type: 'string', + default: '', + + }, + { + displayName: 'Value', + name: 'value', + type: 'string', + default: '', + }, + ]; +} diff --git a/packages/nodes-base/nodes/HttpRequest/HttpRequest.node.ts b/packages/nodes-base/nodes/HttpRequest/HttpRequest.node.ts index 978e41a5bd015..b6826022cdb50 100644 --- a/packages/nodes-base/nodes/HttpRequest/HttpRequest.node.ts +++ b/packages/nodes-base/nodes/HttpRequest/HttpRequest.node.ts @@ -73,6 +73,17 @@ export class HttpRequest implements INodeType { }, }, }, + { + name: 'httpQueryAuth', + required: true, + displayOptions: { + show: { + authentication: [ + 'queryAuth', + ], + }, + }, + }, { name: 'oAuth1Api', required: true, @@ -114,6 +125,10 @@ export class HttpRequest implements INodeType { name: 'Header Auth', value: 'headerAuth', }, + { + name: 'Query Auth', + value: 'queryAuth', + }, { name: 'OAuth1', value: 'oAuth1', @@ -641,6 +656,7 @@ export class HttpRequest implements INodeType { const httpBasicAuth = await this.getCredentials('httpBasicAuth'); const httpDigestAuth = await this.getCredentials('httpDigestAuth'); const httpHeaderAuth = await this.getCredentials('httpHeaderAuth'); + const httpQueryAuth = await this.getCredentials('httpQueryAuth'); const oAuth1Api = await this.getCredentials('oAuth1Api'); const oAuth2Api = await this.getCredentials('oAuth2Api'); @@ -890,6 +906,12 @@ export class HttpRequest implements INodeType { if (httpHeaderAuth !== undefined) { requestOptions.headers![httpHeaderAuth.name as string] = httpHeaderAuth.value; } + if (httpQueryAuth !== undefined) { + if (!requestOptions.qs) { + requestOptions.qs = {}; + } + requestOptions.qs![httpQueryAuth.name as string] = httpQueryAuth.value; + } if (httpDigestAuth !== undefined) { requestOptions.auth = { user: httpDigestAuth.user as string, diff --git a/packages/nodes-base/package.json b/packages/nodes-base/package.json index f60e6637c26ef..2da78b154afc8 100644 --- a/packages/nodes-base/package.json +++ b/packages/nodes-base/package.json @@ -137,6 +137,7 @@ "dist/credentials/HttpBasicAuth.credentials.js", "dist/credentials/HttpDigestAuth.credentials.js", "dist/credentials/HttpHeaderAuth.credentials.js", + "dist/credentials/HttpQueryAuth.credentials.js", "dist/credentials/HubspotApi.credentials.js", "dist/credentials/HubspotDeveloperApi.credentials.js", "dist/credentials/HubspotOAuth2Api.credentials.js",