Skip to content

Commit

Permalink
✨ Add support for Query Auth
Browse files Browse the repository at this point in the history
  • Loading branch information
janober committed Dec 5, 2021
1 parent 703ff4a commit 6453996
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
27 changes: 27 additions & 0 deletions packages/nodes-base/credentials/HttpQueryAuth.credentials.ts
Original file line number Diff line number Diff line change
@@ -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: '',
},
];
}
22 changes: 22 additions & 0 deletions packages/nodes-base/nodes/HttpRequest/HttpRequest.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ export class HttpRequest implements INodeType {
},
},
},
{
name: 'httpQueryAuth',
required: true,
displayOptions: {
show: {
authentication: [
'queryAuth',
],
},
},
},
{
name: 'oAuth1Api',
required: true,
Expand Down Expand Up @@ -114,6 +125,10 @@ export class HttpRequest implements INodeType {
name: 'Header Auth',
value: 'headerAuth',
},
{
name: 'Query Auth',
value: 'queryAuth',
},
{
name: 'OAuth1',
value: 'oAuth1',
Expand Down Expand Up @@ -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');

Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

1 comment on commit 6453996

@pemontto
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌
@janober can this also be used for the webhook and wait nodes? Would be very useful as a verification token in a wait webhook workflow!

Please sign in to comment.