From c2874819b8da429d63bf702d28fed068e4637241 Mon Sep 17 00:00:00 2001 From: agobrech Date: Tue, 3 May 2022 14:18:20 +0200 Subject: [PATCH 01/13] Notion cred updated --- .../nodes-base/credentials/NotionApi.credentials.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/nodes-base/credentials/NotionApi.credentials.ts b/packages/nodes-base/credentials/NotionApi.credentials.ts index 322da316985ea..a6682ff9e2518 100644 --- a/packages/nodes-base/credentials/NotionApi.credentials.ts +++ b/packages/nodes-base/credentials/NotionApi.credentials.ts @@ -1,5 +1,8 @@ import { + ICredentialDataDecryptedObject, + ICredentialTestRequest, ICredentialType, + IHttpRequestOptions, INodeProperties, } from 'n8n-workflow'; @@ -15,4 +18,14 @@ export class NotionApi implements ICredentialType { default: '', }, ]; + test: ICredentialTestRequest = { + request: { + baseURL: 'https://api.notion.com/v1', + url: '/users', + }, + }; + async authenticate(credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions): Promise { + requestOptions.headers!['Authorization'] = `Bearer ${credentials.accessToken}`; + return requestOptions; + } } From 7a422099238ff1ebe1dfedd2255c8d36a7df8a0d Mon Sep 17 00:00:00 2001 From: agobrech Date: Tue, 3 May 2022 14:36:23 +0200 Subject: [PATCH 02/13] Airtable new cred --- packages/nodes-base/credentials/AirtableApi.credentials.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/nodes-base/credentials/AirtableApi.credentials.ts b/packages/nodes-base/credentials/AirtableApi.credentials.ts index 2a3d8cdbfc188..bb0d4d34d6879 100644 --- a/packages/nodes-base/credentials/AirtableApi.credentials.ts +++ b/packages/nodes-base/credentials/AirtableApi.credentials.ts @@ -1,5 +1,8 @@ import { + ICredentialDataDecryptedObject, + ICredentialTestRequest, ICredentialType, + IHttpRequestOptions, INodeProperties, } from 'n8n-workflow'; @@ -16,4 +19,8 @@ export class AirtableApi implements ICredentialType { default: '', }, ]; + async authenticate(credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions): Promise { + requestOptions.headers!['Authorization'] = `Bearer ${credentials.accessToken}`; + return requestOptions; + } } From 80e2e34dc381110b2d70d575c368be12c723ba1f Mon Sep 17 00:00:00 2001 From: agobrech Date: Wed, 11 May 2022 14:49:59 +0200 Subject: [PATCH 03/13] revamped twilio cred --- .../credentials/TwilioApi.credentials.ts | 17 +++++++++++++++++ .../nodes-base/nodes/Twilio/GenericFunctions.ts | 14 +------------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/packages/nodes-base/credentials/TwilioApi.credentials.ts b/packages/nodes-base/credentials/TwilioApi.credentials.ts index df5e1c1f123f6..b59b1e645e039 100644 --- a/packages/nodes-base/credentials/TwilioApi.credentials.ts +++ b/packages/nodes-base/credentials/TwilioApi.credentials.ts @@ -1,5 +1,8 @@ import { + ICredentialDataDecryptedObject, + ICredentialTestRequest, ICredentialType, + IHttpRequestOptions, INodeProperties, } from 'n8n-workflow'; @@ -74,4 +77,18 @@ export class TwilioApi implements ICredentialType { }, }, ]; + async authenticate(credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions): Promise { + if (credentials.authType === 'apiKey') { + requestOptions.auth = { + username: credentials.apiKeySid as string, + password: credentials.apiKeySecret as string, + }; + } else if (credentials.authType === 'authToken') { + requestOptions.auth = { + username: credentials.accountSid as string, + password: credentials.authToken as string, + }; + } + return requestOptions; + } } diff --git a/packages/nodes-base/nodes/Twilio/GenericFunctions.ts b/packages/nodes-base/nodes/Twilio/GenericFunctions.ts index e1612dbe38a01..2d0a37a72cae3 100644 --- a/packages/nodes-base/nodes/Twilio/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Twilio/GenericFunctions.ts @@ -41,20 +41,8 @@ export async function twilioApiRequest(this: IHookFunctions | IExecuteFunctions, json: true, }; - if (credentials.authType === 'apiKey') { - options.auth = { - user: credentials.apiKeySid, - password: credentials.apiKeySecret, - }; - } else if (credentials.authType === 'authToken') { - options.auth = { - user: credentials.accountSid, - pass: credentials.authToken, - }; - } - try { - return await this.helpers.request(options); + return await this.helpers.requestWithAuthentication.call(this, 'twilioApi', options); } catch (error) { throw new NodeApiError(this.getNode(), error); } From 71015d7171f2fd10c4bd192f9161a8a87afcd53d Mon Sep 17 00:00:00 2001 From: agobrech Date: Wed, 11 May 2022 21:35:12 +0200 Subject: [PATCH 04/13] urlscanlo revamp cred --- .../credentials/UrlScanIoApi.credentials.ts | 15 ++++++++ .../nodes/UrlScanIo/GenericFunctions.ts | 4 --- .../nodes/UrlScanIo/UrlScanIo.node.ts | 34 ------------------- 3 files changed, 15 insertions(+), 38 deletions(-) diff --git a/packages/nodes-base/credentials/UrlScanIoApi.credentials.ts b/packages/nodes-base/credentials/UrlScanIoApi.credentials.ts index df29c66cf863d..df9ef4144e915 100644 --- a/packages/nodes-base/credentials/UrlScanIoApi.credentials.ts +++ b/packages/nodes-base/credentials/UrlScanIoApi.credentials.ts @@ -1,4 +1,6 @@ import { + IAuthenticateHeaderAuth, + ICredentialTestRequest, ICredentialType, INodeProperties, } from 'n8n-workflow'; @@ -16,4 +18,17 @@ export class UrlScanIoApi implements ICredentialType { required: true, }, ]; + authenticate = { + type: 'headerAuth', + properties: { + name: 'API-KEY', + value: '={{$credentials.apiKey}}', + }, + } as IAuthenticateHeaderAuth; + test: ICredentialTestRequest = { + request: { + baseURL: 'https://urlscan.io', + url: '/user/quotas', + }, + }; } diff --git a/packages/nodes-base/nodes/UrlScanIo/GenericFunctions.ts b/packages/nodes-base/nodes/UrlScanIo/GenericFunctions.ts index 8a3d5deaf665a..f58604ae8e7b3 100644 --- a/packages/nodes-base/nodes/UrlScanIo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/UrlScanIo/GenericFunctions.ts @@ -18,12 +18,8 @@ export async function urlScanIoApiRequest( body: IDataObject = {}, qs: IDataObject = {}, ) { - const { apiKey } = await this.getCredentials('urlScanIoApi') as { apiKey: string }; const options: OptionsWithUri = { - headers: { - 'API-KEY': apiKey, - }, method, body, qs, diff --git a/packages/nodes-base/nodes/UrlScanIo/UrlScanIo.node.ts b/packages/nodes-base/nodes/UrlScanIo/UrlScanIo.node.ts index 78076b1d1ba6d..b7e9dd7b28c74 100644 --- a/packages/nodes-base/nodes/UrlScanIo/UrlScanIo.node.ts +++ b/packages/nodes-base/nodes/UrlScanIo/UrlScanIo.node.ts @@ -46,7 +46,6 @@ export class UrlScanIo implements INodeType { { name: 'urlScanIoApi', required: true, - testedBy: 'urlScanIoApiTest', }, ], properties: [ @@ -68,39 +67,6 @@ export class UrlScanIo implements INodeType { ], }; - methods = { - credentialTest: { - async urlScanIoApiTest( - this: ICredentialTestFunctions, - credentials: ICredentialsDecrypted, - ): Promise { - const { apiKey } = credentials.data as { apiKey: string }; - - const options: OptionsWithUri = { - headers: { - 'API-KEY': apiKey, - }, - method: 'GET', - uri: 'https://urlscan.io/user/quotas', - json: true, - }; - - try { - await this.helpers.request(options); - return { - status: 'OK', - message: 'Authentication successful', - }; - } catch (error) { - return { - status: 'Error', - message: error.message, - }; - } - }, - }, - }; - async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); const returnData: IDataObject[] = []; From 4fe4b328a79599943a6b987d9016a7ba15bf0eaf Mon Sep 17 00:00:00 2001 From: agobrech Date: Wed, 11 May 2022 23:20:54 +0200 Subject: [PATCH 05/13] Wordpress revamp cred with testing --- packages/nodes-base/credentials/WordpressApi.credentials.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/nodes-base/credentials/WordpressApi.credentials.ts b/packages/nodes-base/credentials/WordpressApi.credentials.ts index ade71b8582042..47dd3585d22e3 100644 --- a/packages/nodes-base/credentials/WordpressApi.credentials.ts +++ b/packages/nodes-base/credentials/WordpressApi.credentials.ts @@ -50,3 +50,4 @@ export class WordpressApi implements ICredentialType { }, }; } + From ee5ea3f5fcd5e522497754c21b7b1261a1b5049d Mon Sep 17 00:00:00 2001 From: agobrech Date: Mon, 16 May 2022 11:16:38 +0200 Subject: [PATCH 06/13] SendGrid cred revamped --- .../nodes-base/credentials/SendGridApi.credentials.ts | 9 +++++++++ packages/nodes-base/nodes/SendGrid/GenericFunctions.ts | 6 +----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/nodes-base/credentials/SendGridApi.credentials.ts b/packages/nodes-base/credentials/SendGridApi.credentials.ts index d2338f4419d04..deca1b09a9628 100644 --- a/packages/nodes-base/credentials/SendGridApi.credentials.ts +++ b/packages/nodes-base/credentials/SendGridApi.credentials.ts @@ -1,4 +1,6 @@ import { + IAuthenticate, + IAuthenticateHeaderAuth, ICredentialType, INodeProperties, } from 'n8n-workflow'; @@ -15,4 +17,11 @@ export class SendGridApi implements ICredentialType { default: '', }, ]; + authenticate = { + type: 'headerAuth', + properties: { + name: 'Authorization', + value: '=Bearer {{$credentials.apiKey}}', + }, + } as IAuthenticateHeaderAuth; } diff --git a/packages/nodes-base/nodes/SendGrid/GenericFunctions.ts b/packages/nodes-base/nodes/SendGrid/GenericFunctions.ts index 4787312b6ba81..7021922819d8e 100644 --- a/packages/nodes-base/nodes/SendGrid/GenericFunctions.ts +++ b/packages/nodes-base/nodes/SendGrid/GenericFunctions.ts @@ -14,14 +14,10 @@ import { } from 'n8n-workflow'; export async function sendGridApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, endpoint: string, method: string, body: any = {}, qs: IDataObject = {}, option: IDataObject = {}): Promise { // tslint:disable-line:no-any - const credentials = await this.getCredentials('sendGridApi'); const host = 'api.sendgrid.com/v3'; const options: OptionsWithUri = { - headers: { - Authorization: `Bearer ${credentials.apiKey}`, - }, method, qs, body, @@ -39,7 +35,7 @@ export async function sendGridApiRequest(this: IHookFunctions | IExecuteFunction try { //@ts-ignore - return await this.helpers.request!(options); + return await this.helpers.requestWithAuthentication.call(this, 'sendgrid', options); } catch (error) { throw new NodeApiError(this.getNode(), error); } From 2795a2a7edfbb63f1df8d116e19398fce653e6c6 Mon Sep 17 00:00:00 2001 From: agobrech Date: Thu, 7 Jul 2022 10:16:11 +0200 Subject: [PATCH 07/13] =?UTF-8?q?=F0=9F=90=9B=20Fix=20imports?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nodes-base/credentials/SendGridApi.credentials.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/nodes-base/credentials/SendGridApi.credentials.ts b/packages/nodes-base/credentials/SendGridApi.credentials.ts index deca1b09a9628..b80c45a0f4491 100644 --- a/packages/nodes-base/credentials/SendGridApi.credentials.ts +++ b/packages/nodes-base/credentials/SendGridApi.credentials.ts @@ -1,6 +1,5 @@ import { - IAuthenticate, - IAuthenticateHeaderAuth, + IAuthenticateGeneric, ICredentialType, INodeProperties, } from 'n8n-workflow'; @@ -18,10 +17,9 @@ export class SendGridApi implements ICredentialType { }, ]; authenticate = { - type: 'headerAuth', + type: 'generic', properties: { - name: 'Authorization', - value: '=Bearer {{$credentials.apiKey}}', + Authorization: '=Bearer {{$credentials.apiKey}}', }, - } as IAuthenticateHeaderAuth; + } as IAuthenticateGeneric; } From 16c299d814143c72a412eb1469a059c956a87431 Mon Sep 17 00:00:00 2001 From: agobrech Date: Thu, 7 Jul 2022 10:19:41 +0200 Subject: [PATCH 08/13] =?UTF-8?q?=F0=9F=90=9B=20=20Fixes=20imports=20in=20?= =?UTF-8?q?urlscanio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nodes-base/credentials/UrlScanIoApi.credentials.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/nodes-base/credentials/UrlScanIoApi.credentials.ts b/packages/nodes-base/credentials/UrlScanIoApi.credentials.ts index df9ef4144e915..f8eb78892f497 100644 --- a/packages/nodes-base/credentials/UrlScanIoApi.credentials.ts +++ b/packages/nodes-base/credentials/UrlScanIoApi.credentials.ts @@ -1,5 +1,5 @@ import { - IAuthenticateHeaderAuth, + IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties, @@ -19,12 +19,12 @@ export class UrlScanIoApi implements ICredentialType { }, ]; authenticate = { - type: 'headerAuth', + type: 'generic', properties: { - name: 'API-KEY', - value: '={{$credentials.apiKey}}', + 'API-KEY': '={{$credentials.apiKey}}', }, - } as IAuthenticateHeaderAuth; + } as IAuthenticateGeneric; + test: ICredentialTestRequest = { request: { baseURL: 'https://urlscan.io', From cfaf060ee12fb3373dc808d2f121c5a1c99bcd5f Mon Sep 17 00:00:00 2001 From: Omar Ajoue Date: Thu, 7 Jul 2022 15:18:46 +0200 Subject: [PATCH 09/13] Fix airtable cred injection --- .../credentials/AirtableApi.credentials.ts | 2 +- .../nodes-base/nodes/Airtable/GenericFunctions.ts | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/nodes-base/credentials/AirtableApi.credentials.ts b/packages/nodes-base/credentials/AirtableApi.credentials.ts index bb0d4d34d6879..068a2f5e28e05 100644 --- a/packages/nodes-base/credentials/AirtableApi.credentials.ts +++ b/packages/nodes-base/credentials/AirtableApi.credentials.ts @@ -20,7 +20,7 @@ export class AirtableApi implements ICredentialType { }, ]; async authenticate(credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions): Promise { - requestOptions.headers!['Authorization'] = `Bearer ${credentials.accessToken}`; + requestOptions.headers!['Authorization'] = `Bearer ${credentials.apiKey}`; return requestOptions; } } diff --git a/packages/nodes-base/nodes/Airtable/GenericFunctions.ts b/packages/nodes-base/nodes/Airtable/GenericFunctions.ts index 1f6b5b2ffbe57..307b1d70f8026 100644 --- a/packages/nodes-base/nodes/Airtable/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Airtable/GenericFunctions.ts @@ -1,7 +1,6 @@ import { IExecuteFunctions, - IHookFunctions, - ILoadOptionsFunctions, + IPollFunctions, } from 'n8n-core'; import { @@ -12,9 +11,9 @@ import { IBinaryKeyData, IDataObject, INodeExecutionData, - IPollFunctions, NodeApiError, NodeOperationError, + ILoadOptionsFunctions, } from 'n8n-workflow'; @@ -39,7 +38,7 @@ export interface IRecord { * @param {object} body * @returns {Promise} */ -export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, method: string, endpoint: string, body: object, query?: IDataObject, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function apiRequest(this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, method: string, endpoint: string, body: object, query?: IDataObject, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any const credentials = await this.getCredentials('airtableApi'); query = query || {}; @@ -47,7 +46,7 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa // For some reason for some endpoints the bearer auth does not work // and it returns 404 like for the /meta request. So we always send // it as query string. - query.api_key = credentials.apiKey; + // query.api_key = credentials.apiKey; const options: OptionsWithUri = { headers: { @@ -69,7 +68,7 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa } try { - return await this.helpers.request!(options); + return await this.helpers.requestWithAuthentication.call(this, 'airtableApi', options); } catch (error) { throw new NodeApiError(this.getNode(), error); } @@ -81,14 +80,14 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa * and return all results * * @export - * @param {(IHookFunctions | IExecuteFunctions)} this + * @param {(IExecuteFunctions | IExecuteFunctions)} this * @param {string} method * @param {string} endpoint * @param {IDataObject} body * @param {IDataObject} [query] * @returns {Promise} */ -export async function apiRequestAllItems(this: IHookFunctions | IExecuteFunctions | IPollFunctions, method: string, endpoint: string, body: IDataObject, query?: IDataObject): Promise { // tslint:disable-line:no-any +export async function apiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, method: string, endpoint: string, body: IDataObject, query?: IDataObject): Promise { // tslint:disable-line:no-any if (query === undefined) { query = {}; From d0fd754bf581455bcb5e239380ddbab1a2814301 Mon Sep 17 00:00:00 2001 From: agobrech Date: Thu, 7 Jul 2022 16:13:56 +0200 Subject: [PATCH 10/13] Fixes notion request, changes way of cred injection --- .../credentials/NotionApi.credentials.ts | 15 +++++++++------ .../nodes-base/nodes/Notion/GenericFunctions.ts | 8 +++----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/packages/nodes-base/credentials/NotionApi.credentials.ts b/packages/nodes-base/credentials/NotionApi.credentials.ts index a6682ff9e2518..1c8e53a79f9d4 100644 --- a/packages/nodes-base/credentials/NotionApi.credentials.ts +++ b/packages/nodes-base/credentials/NotionApi.credentials.ts @@ -1,8 +1,7 @@ import { - ICredentialDataDecryptedObject, + IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, - IHttpRequestOptions, INodeProperties, } from 'n8n-workflow'; @@ -24,8 +23,12 @@ export class NotionApi implements ICredentialType { url: '/users', }, }; - async authenticate(credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions): Promise { - requestOptions.headers!['Authorization'] = `Bearer ${credentials.accessToken}`; - return requestOptions; - } + authenticate: IAuthenticateGeneric = { + type: 'generic', + properties: { + headers: { + 'Authorization': '=Bearer {{$credentials.apiKey}}', + }, + }, + }; } diff --git a/packages/nodes-base/nodes/Notion/GenericFunctions.ts b/packages/nodes-base/nodes/Notion/GenericFunctions.ts index 7344545879651..942e5856bd613 100644 --- a/packages/nodes-base/nodes/Notion/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Notion/GenericFunctions.ts @@ -55,14 +55,12 @@ export async function notionApiRequest(this: IHookFunctions | IExecuteFunctions json: true, }; options = Object.assign({}, options, option); - const credentials = await this.getCredentials('notionApi'); - if (!uri) { - //do not include the API Key when downloading files, else the request fails - options!.headers!['Authorization'] = `Bearer ${credentials.apiKey}`; - } if (Object.keys(body).length === 0) { delete options.body; } + if (!uri) { + return this.helpers.requestWithAuthentication.call(this,'notionApi', options ); + } return this.helpers.request!(options); } catch (error) { From 3815818620e2c3a921a7c4c4f4ec4db0fd0598de Mon Sep 17 00:00:00 2001 From: agobrech Date: Thu, 7 Jul 2022 16:25:35 +0200 Subject: [PATCH 11/13] Change auth type from method to generic --- .../credentials/AirtableApi.credentials.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/nodes-base/credentials/AirtableApi.credentials.ts b/packages/nodes-base/credentials/AirtableApi.credentials.ts index 068a2f5e28e05..a9b023b2c85d6 100644 --- a/packages/nodes-base/credentials/AirtableApi.credentials.ts +++ b/packages/nodes-base/credentials/AirtableApi.credentials.ts @@ -1,8 +1,6 @@ import { - ICredentialDataDecryptedObject, - ICredentialTestRequest, + IAuthenticateGeneric, ICredentialType, - IHttpRequestOptions, INodeProperties, } from 'n8n-workflow'; @@ -19,8 +17,12 @@ export class AirtableApi implements ICredentialType { default: '', }, ]; - async authenticate(credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions): Promise { - requestOptions.headers!['Authorization'] = `Bearer ${credentials.apiKey}`; - return requestOptions; - } + authenticate: IAuthenticateGeneric = { + type: 'generic', + properties: { + headers: { + Authorization: '={{$credentials.apiKey}}', + }, + }, + }; } From 5f12f1fd96ab1270745c4a1f5210455a2f6b2e92 Mon Sep 17 00:00:00 2001 From: Omar Ajoue Date: Fri, 8 Jul 2022 14:42:11 +0200 Subject: [PATCH 12/13] Fix minor issues --- .../credentials/SendGridApi.credentials.ts | 4 ++- .../credentials/TwilioApi.credentials.ts | 25 ++++++++----------- .../credentials/UrlScanIoApi.credentials.ts | 4 ++- .../nodes/SendGrid/GenericFunctions.ts | 2 +- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/packages/nodes-base/credentials/SendGridApi.credentials.ts b/packages/nodes-base/credentials/SendGridApi.credentials.ts index b80c45a0f4491..95ee72d1c5b5c 100644 --- a/packages/nodes-base/credentials/SendGridApi.credentials.ts +++ b/packages/nodes-base/credentials/SendGridApi.credentials.ts @@ -19,7 +19,9 @@ export class SendGridApi implements ICredentialType { authenticate = { type: 'generic', properties: { - Authorization: '=Bearer {{$credentials.apiKey}}', + headers: { + Authorization: '=Bearer {{$credentials.apiKey}}', + }, }, } as IAuthenticateGeneric; } diff --git a/packages/nodes-base/credentials/TwilioApi.credentials.ts b/packages/nodes-base/credentials/TwilioApi.credentials.ts index b59b1e645e039..802d4917ee4eb 100644 --- a/packages/nodes-base/credentials/TwilioApi.credentials.ts +++ b/packages/nodes-base/credentials/TwilioApi.credentials.ts @@ -1,4 +1,5 @@ import { + IAuthenticateGeneric, ICredentialDataDecryptedObject, ICredentialTestRequest, ICredentialType, @@ -77,18 +78,14 @@ export class TwilioApi implements ICredentialType { }, }, ]; - async authenticate(credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions): Promise { - if (credentials.authType === 'apiKey') { - requestOptions.auth = { - username: credentials.apiKeySid as string, - password: credentials.apiKeySecret as string, - }; - } else if (credentials.authType === 'authToken') { - requestOptions.auth = { - username: credentials.accountSid as string, - password: credentials.authToken as string, - }; - } - return requestOptions; - } + + authenticate: IAuthenticateGeneric = { + type: 'generic', + properties: { + auth: { + username: '={{ $credentials.authType === "apiKey" ? $credentials.apiKeySid : $credentials.accountSid }}', + password: '={{ $credentials.authType === "apiKey" ? $credentials.apiKeySecret : $credentials.authToken }}', + }, + }, + }; } diff --git a/packages/nodes-base/credentials/UrlScanIoApi.credentials.ts b/packages/nodes-base/credentials/UrlScanIoApi.credentials.ts index f8eb78892f497..299386d59b99c 100644 --- a/packages/nodes-base/credentials/UrlScanIoApi.credentials.ts +++ b/packages/nodes-base/credentials/UrlScanIoApi.credentials.ts @@ -21,7 +21,9 @@ export class UrlScanIoApi implements ICredentialType { authenticate = { type: 'generic', properties: { - 'API-KEY': '={{$credentials.apiKey}}', + headers: { + 'API-KEY': '={{$credentials.apiKey}}', + }, }, } as IAuthenticateGeneric; diff --git a/packages/nodes-base/nodes/SendGrid/GenericFunctions.ts b/packages/nodes-base/nodes/SendGrid/GenericFunctions.ts index 7021922819d8e..aacf6da5068bf 100644 --- a/packages/nodes-base/nodes/SendGrid/GenericFunctions.ts +++ b/packages/nodes-base/nodes/SendGrid/GenericFunctions.ts @@ -35,7 +35,7 @@ export async function sendGridApiRequest(this: IHookFunctions | IExecuteFunction try { //@ts-ignore - return await this.helpers.requestWithAuthentication.call(this, 'sendgrid', options); + return await this.helpers.requestWithAuthentication.call(this, 'sendGridApi', options); } catch (error) { throw new NodeApiError(this.getNode(), error); } From 42742d435f56d6efd5890969637e45bc6c0c78ce Mon Sep 17 00:00:00 2001 From: Omar Ajoue Date: Fri, 8 Jul 2022 14:46:47 +0200 Subject: [PATCH 13/13] Fix lint issue --- packages/nodes-base/nodes/Airtable/GenericFunctions.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/nodes-base/nodes/Airtable/GenericFunctions.ts b/packages/nodes-base/nodes/Airtable/GenericFunctions.ts index 307b1d70f8026..05057a6e3faf5 100644 --- a/packages/nodes-base/nodes/Airtable/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Airtable/GenericFunctions.ts @@ -10,10 +10,9 @@ import { import { IBinaryKeyData, IDataObject, + ILoadOptionsFunctions, INodeExecutionData, NodeApiError, - NodeOperationError, - ILoadOptionsFunctions, } from 'n8n-workflow';