mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
feat: Add more credentials tests (#3668)
* ✨ Add injection to notion, Add test to notion in cred * 🔥 Remove unuse method * 🎨 Move testing from node file to cred file * ✨ Add injection and testing in facebook graph * Add cred injec with testing * Add Cred injection and cred test * Add cred injection, and cred testing for typeform, fix issue in clickup * Add cred injection, move testing inside creds * Add cred injection and cred testing to SendGrid * Add cred injection and cred testing to woocommerce * Add cred injection, add cred test to gitlab * 🔥 Fix duplicated imports in Mautic cred * 🔥 removed unused credentials testing in node * Add cred injection, cred testing, handles slash trailing for Grafana node * Add cred injection, cred testing to shopify * Add cred injection , add cred testing to stripe * changed cred injection, add testing to cred for mattermost * add cred injection and testing for dropbox * Add cred injection, cred testing to webflow * ✨ Add cred injection and cred test to nocodb * ✨ Add cred injection, cred testing to mailchimp * 🐛 fix a bug In credentials testing * ✨ Add cred injection, cred testing to sms77 * ✨ Add cred injection, cred testing to ActiveCampaign * Add cred injection, cred testing to TheHive * ✨ Add cred injection, add cred testing to ApiTemplateio * ✨ Add cred injection, add cred testing for zoom * ✨ Add cred injection, cred testing to rocketchat * ✨ Add cred injection, add cred test to getResponse * 🔥 Remove useless authentcate creds and testing from facebookGraphApp * 🔥 Remove useless imports in FacebookGrappApp credentials file * 🔥 Removed useless imports and if statement * 🐛 Add version to header when testing cred Co-authored-by: Omar Ajoue <krynble@gmail.com> Co-authored-by: Jan Oberhauser <janober@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
|
IAuthenticateGeneric,
|
||||||
|
ICredentialTestRequest,
|
||||||
ICredentialType,
|
ICredentialType,
|
||||||
INodeProperties,
|
INodeProperties,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
@@ -22,4 +24,18 @@ export class ActiveCampaignApi implements ICredentialType {
|
|||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
authenticate: IAuthenticateGeneric = {
|
||||||
|
type: 'generic',
|
||||||
|
properties: {
|
||||||
|
headers: {
|
||||||
|
'Api-Token': '={{$credentials.apiKey}}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
test: ICredentialTestRequest = {
|
||||||
|
request: {
|
||||||
|
baseURL: '={{$credentials.apiUrl}}',
|
||||||
|
url: '/api/3/fields',
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
|
IAuthenticateGeneric,
|
||||||
|
ICredentialTestRequest,
|
||||||
ICredentialType,
|
ICredentialType,
|
||||||
INodeProperties,
|
INodeProperties,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
@@ -15,4 +17,18 @@ export class ApiTemplateIoApi implements ICredentialType {
|
|||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
authenticate: IAuthenticateGeneric = {
|
||||||
|
type: 'generic',
|
||||||
|
properties: {
|
||||||
|
headers: {
|
||||||
|
'X-API-KEY': '={{$credentials.apiKey}}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
test: ICredentialTestRequest = {
|
||||||
|
request: {
|
||||||
|
baseURL: 'https://api.apitemplate.io/v1',
|
||||||
|
url: '/list-templates',
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
|
IAuthenticateGeneric,
|
||||||
|
ICredentialTestRequest,
|
||||||
ICredentialType,
|
ICredentialType,
|
||||||
INodeProperties,
|
INodeProperties,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
@@ -15,4 +17,19 @@ export class ClickUpApi implements ICredentialType {
|
|||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
authenticate: IAuthenticateGeneric = {
|
||||||
|
type: 'generic',
|
||||||
|
properties: {
|
||||||
|
headers: {
|
||||||
|
Authorization: '={{$credentials.accessToken}}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
test: ICredentialTestRequest = {
|
||||||
|
request: {
|
||||||
|
baseURL: 'https://api.clickup.com/api/v2',
|
||||||
|
url: '/team',
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import {
|
import {
|
||||||
|
IAuthenticateGeneric,
|
||||||
|
ICredentialTestFunction,
|
||||||
|
ICredentialTestRequest,
|
||||||
ICredentialType,
|
ICredentialType,
|
||||||
INodeProperties,
|
INodeProperties
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
export class DropboxApi implements ICredentialType {
|
export class DropboxApi implements ICredentialType {
|
||||||
@@ -31,4 +34,20 @@ export class DropboxApi implements ICredentialType {
|
|||||||
default: 'full',
|
default: 'full',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
authenticate: IAuthenticateGeneric = {
|
||||||
|
type: 'generic',
|
||||||
|
properties: {
|
||||||
|
headers: {
|
||||||
|
Authorization: '=Bearer {{$credentials.accessToken}}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
test: ICredentialTestRequest = {
|
||||||
|
request: {
|
||||||
|
baseURL: 'https://api.dropboxapi.com/2',
|
||||||
|
url: '/users/get_current_account',
|
||||||
|
method: 'POST',
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
|
IAuthenticateGeneric,
|
||||||
|
ICredentialTestRequest,
|
||||||
ICredentialType,
|
ICredentialType,
|
||||||
INodeProperties,
|
INodeProperties,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
@@ -16,4 +18,18 @@ export class FacebookGraphApi implements ICredentialType {
|
|||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
authenticate: IAuthenticateGeneric = {
|
||||||
|
type: 'generic',
|
||||||
|
properties: {
|
||||||
|
qs: {
|
||||||
|
access_token: '={{$credentials.accessToken}}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
test: ICredentialTestRequest = {
|
||||||
|
request: {
|
||||||
|
baseURL: 'https://graph.facebook.com/v8.0',
|
||||||
|
url: '/me',
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
|
IAuthenticateGeneric,
|
||||||
|
ICredentialTestRequest,
|
||||||
ICredentialType,
|
ICredentialType,
|
||||||
INodeProperties,
|
INodeProperties,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
@@ -15,4 +17,18 @@ export class GetResponseApi implements ICredentialType {
|
|||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
authenticate: IAuthenticateGeneric = {
|
||||||
|
type: 'generic',
|
||||||
|
properties: {
|
||||||
|
headers: {
|
||||||
|
'X-Auth-Token': '=api-key {{$credentials.apiKey}}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
test: ICredentialTestRequest = {
|
||||||
|
request: {
|
||||||
|
baseURL: 'https://api.getresponse.com/v3',
|
||||||
|
url: '/campaigns',
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
|
IAuthenticateGeneric,
|
||||||
|
ICredentialTestRequest,
|
||||||
ICredentialType,
|
ICredentialType,
|
||||||
INodeProperties,
|
INodeProperties,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
@@ -22,4 +24,19 @@ export class GitlabApi implements ICredentialType {
|
|||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
authenticate: IAuthenticateGeneric = {
|
||||||
|
type: 'generic',
|
||||||
|
properties: {
|
||||||
|
headers: {
|
||||||
|
'Private-Token': '={{$credentials.accessToken}}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
test: ICredentialTestRequest = {
|
||||||
|
request: {
|
||||||
|
baseURL: '={{$credentials.server.replace(new RegExp("/$"), "") + "/api/v4" }}',
|
||||||
|
url: '/users',
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
|
IAuthenticateGeneric,
|
||||||
|
ICredentialTestRequest,
|
||||||
ICredentialType,
|
ICredentialType,
|
||||||
INodeProperties,
|
INodeProperties,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
@@ -25,4 +27,19 @@ export class GrafanaApi implements ICredentialType {
|
|||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
authenticate: IAuthenticateGeneric = {
|
||||||
|
type: 'generic',
|
||||||
|
properties: {
|
||||||
|
headers: {
|
||||||
|
Authorization: '=Bearer {{$credentials.apiKey}}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
test: ICredentialTestRequest = {
|
||||||
|
request: {
|
||||||
|
baseURL: '={{$credentials.baseUrl.replace(new RegExp("/$"), "") + "/api" }}',
|
||||||
|
url: '/folders',
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
|
IAuthenticateGeneric,
|
||||||
|
ICredentialTestFunctions,
|
||||||
|
ICredentialTestRequest,
|
||||||
ICredentialType,
|
ICredentialType,
|
||||||
INodeProperties,
|
INodeProperties,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
@@ -15,4 +18,18 @@ export class MailchimpApi implements ICredentialType {
|
|||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
authenticate: IAuthenticateGeneric = {
|
||||||
|
type:'generic',
|
||||||
|
properties:{
|
||||||
|
headers:{
|
||||||
|
Authorization: '=apikey {{$credentials.apiKey}}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
test: ICredentialTestRequest = {
|
||||||
|
request: {
|
||||||
|
baseURL: '=https://{{$credentials.apiKey.split("-").pop()}}.api.mailchimp.com/3.0',
|
||||||
|
url: '/lists',
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
|
IAuthenticateGeneric,
|
||||||
ICredentialDataDecryptedObject,
|
ICredentialDataDecryptedObject,
|
||||||
|
ICredentialTestRequest,
|
||||||
ICredentialType,
|
ICredentialType,
|
||||||
IHttpRequestOptions,
|
IHttpRequestOptions,
|
||||||
INodeProperties,
|
INodeProperties,
|
||||||
@@ -24,8 +26,18 @@ export class MattermostApi implements ICredentialType {
|
|||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
async authenticate(credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions> {
|
authenticate: IAuthenticateGeneric = {
|
||||||
requestOptions.headers!['Authorization'] = `Bearer ${credentials.accessToken}`;
|
type: 'generic',
|
||||||
return requestOptions;
|
properties: {
|
||||||
}
|
headers: {
|
||||||
|
Authorization: '=Bearer {{$credentials.accessToken}}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
test: ICredentialTestRequest = {
|
||||||
|
request: {
|
||||||
|
baseURL: '={{$credentials.baseUrl}}/api/v4',
|
||||||
|
url: '/users',
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import {
|
import {
|
||||||
ICredentialType,
|
ICredentialDataDecryptedObject,
|
||||||
INodeProperties,
|
ICredentialTestRequest,
|
||||||
|
ICredentialType,
|
||||||
|
IHttpRequestOptions,
|
||||||
|
INodeProperties,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
export class MauticApi implements ICredentialType {
|
export class MauticApi implements ICredentialType {
|
||||||
@@ -31,4 +34,28 @@ export class MauticApi implements ICredentialType {
|
|||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
async authenticate (credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions> {
|
||||||
|
const {
|
||||||
|
url,
|
||||||
|
username,
|
||||||
|
password,
|
||||||
|
} = credentials as {
|
||||||
|
url: string,
|
||||||
|
username: string,
|
||||||
|
password: string,
|
||||||
|
};
|
||||||
|
const credentialUrl = url.endsWith('/') ? `${url}api/users/self` : `${url}/api/users/self`;
|
||||||
|
const base64Key = Buffer.from(`${username}:${password}`).toString('base64');
|
||||||
|
requestOptions.headers!['Authorization'] = `Basic ${base64Key}`;
|
||||||
|
requestOptions.url = credentialUrl ? credentialUrl : requestOptions.url;
|
||||||
|
|
||||||
|
return requestOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
test: ICredentialTestRequest = {
|
||||||
|
request: {
|
||||||
|
baseURL: '={{$credentials.url.replace(new RegExp("/$"), "")}}',
|
||||||
|
url: '/api/users/self',
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
|
IAuthenticateGeneric,
|
||||||
|
ICredentialTestRequest,
|
||||||
ICredentialType,
|
ICredentialType,
|
||||||
INodeProperties,
|
INodeProperties,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
@@ -23,4 +25,18 @@ export class NocoDb implements ICredentialType {
|
|||||||
placeholder: 'http(s)://localhost:8080',
|
placeholder: 'http(s)://localhost:8080',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
authenticate: IAuthenticateGeneric = {
|
||||||
|
type:'generic',
|
||||||
|
properties: {
|
||||||
|
headers:{
|
||||||
|
'xc-auth': '={{credentials.apiToken}}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
test: ICredentialTestRequest = {
|
||||||
|
request: {
|
||||||
|
baseURL: '={{$credentials.host}}',
|
||||||
|
url: '/lists',
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ export class NotionApi implements ICredentialType {
|
|||||||
properties: {
|
properties: {
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': '=Bearer {{$credentials.apiKey}}',
|
'Authorization': '=Bearer {{$credentials.apiKey}}',
|
||||||
|
'Notion-Version': '2021-05-13',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
|
IAuthenticateGeneric,
|
||||||
|
ICredentialTestRequest,
|
||||||
ICredentialType,
|
ICredentialType,
|
||||||
INodeProperties,
|
INodeProperties,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
@@ -29,4 +31,19 @@ export class RocketchatApi implements ICredentialType {
|
|||||||
placeholder: 'https://n8n.rocket.chat',
|
placeholder: 'https://n8n.rocket.chat',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
authenticate: IAuthenticateGeneric = {
|
||||||
|
type: 'generic',
|
||||||
|
properties: {
|
||||||
|
headers: {
|
||||||
|
'X-Auth-Token': '={{$credentials.authKey}}',
|
||||||
|
'X-User-Id': '={{$credentials.userId}}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
test: ICredentialTestRequest = {
|
||||||
|
request: {
|
||||||
|
baseURL: '={{$credentials.domain}}',
|
||||||
|
url: '/api/v1/webdav.getMyAccounts',
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
IAuthenticateGeneric,
|
IAuthenticateGeneric,
|
||||||
|
ICredentialTestRequest,
|
||||||
ICredentialType,
|
ICredentialType,
|
||||||
INodeProperties,
|
INodeProperties,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
@@ -16,12 +17,19 @@ export class SendGridApi implements ICredentialType {
|
|||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
authenticate = {
|
authenticate: IAuthenticateGeneric = {
|
||||||
type: 'generic',
|
type: 'generic',
|
||||||
properties: {
|
properties: {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: '=Bearer {{$credentials.apiKey}}',
|
Authorization: '=Bearer {{$credentials.apiKey}}',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} as IAuthenticateGeneric;
|
};
|
||||||
|
|
||||||
|
test: ICredentialTestRequest = {
|
||||||
|
request: {
|
||||||
|
baseURL: 'https://api.sendgrid.com/v3',
|
||||||
|
url: '/marketing/contacts',
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
|
import { BINARY_ENCODING } from 'n8n-core';
|
||||||
import {
|
import {
|
||||||
|
IAuthenticateGeneric,
|
||||||
|
ICredentialDataDecryptedObject,
|
||||||
|
ICredentialTestRequest,
|
||||||
ICredentialType,
|
ICredentialType,
|
||||||
|
IHttpRequestOptions,
|
||||||
INodeProperties,
|
INodeProperties,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
@@ -37,4 +42,18 @@ export class ShopifyApi implements ICredentialType {
|
|||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
async authenticate(credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions> {
|
||||||
|
requestOptions.headers = {
|
||||||
|
...requestOptions.headers,
|
||||||
|
Authorization: `Basic ${Buffer.from(`${credentials.apiKey}:${credentials.password}`).toString(BINARY_ENCODING)}`,
|
||||||
|
};
|
||||||
|
return requestOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
test: ICredentialTestRequest = {
|
||||||
|
request: {
|
||||||
|
baseURL: '=https://{{$credentials.shopSubdomain}}.myshopify.com/admin/api/2019-10',
|
||||||
|
url: '/products.json',
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
|
IAuthenticateGeneric,
|
||||||
|
ICredentialTestRequest,
|
||||||
ICredentialType,
|
ICredentialType,
|
||||||
INodeProperties,
|
INodeProperties,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
@@ -15,4 +17,18 @@ export class Sms77Api implements ICredentialType {
|
|||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
authenticate: IAuthenticateGeneric = {
|
||||||
|
type: 'generic',
|
||||||
|
properties: {
|
||||||
|
headers: {
|
||||||
|
'X-Api-Key': '={{$credentials.apiKey}}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
test: ICredentialTestRequest = {
|
||||||
|
request: {
|
||||||
|
baseURL: 'https://gateway.sms77.io/api',
|
||||||
|
url: '/balance',
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
|
IAuthenticateGeneric,
|
||||||
|
ICredentialTestRequest,
|
||||||
ICredentialType,
|
ICredentialType,
|
||||||
INodeProperties,
|
INodeProperties,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
@@ -9,9 +11,6 @@ export class StripeApi implements ICredentialType {
|
|||||||
displayName = 'Stripe API';
|
displayName = 'Stripe API';
|
||||||
documentationUrl = 'stripe';
|
documentationUrl = 'stripe';
|
||||||
properties: INodeProperties[] = [
|
properties: INodeProperties[] = [
|
||||||
// The credentials to get from user and save encrypted.
|
|
||||||
// Properties can be defined exactly in the same way
|
|
||||||
// as node properties.
|
|
||||||
{
|
{
|
||||||
displayName: 'Secret Key',
|
displayName: 'Secret Key',
|
||||||
name: 'secretKey',
|
name: 'secretKey',
|
||||||
@@ -19,4 +18,19 @@ export class StripeApi implements ICredentialType {
|
|||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
authenticate: IAuthenticateGeneric = {
|
||||||
|
type: 'generic',
|
||||||
|
properties: {
|
||||||
|
headers: {
|
||||||
|
Authorization: '=Bearer {{$credentials.secretKey}}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
test: ICredentialTestRequest = {
|
||||||
|
request: {
|
||||||
|
baseURL: 'https://api.stripe.com/v1',
|
||||||
|
url: '/charges',
|
||||||
|
json: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,11 +18,11 @@ export class TelegramApi implements ICredentialType {
|
|||||||
description: 'Chat with the <a href="https://telegram.me/botfather">bot father</a> to obtain the access token',
|
description: 'Chat with the <a href="https://telegram.me/botfather">bot father</a> to obtain the access token',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
test: ICredentialTestRequest = {
|
test: ICredentialTestRequest = {
|
||||||
request: {
|
request: {
|
||||||
baseURL: `=https://api.telegram.org/bot{{$credentials?.accessToken}}`,
|
baseURL: '=https://api.telegram.org/bot{{$credentials.accessToken}}',
|
||||||
url: '/getMe',
|
url: '/getMe',
|
||||||
method: 'GET',
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
|
IAuthenticateGeneric,
|
||||||
|
ICredentialTestRequest,
|
||||||
ICredentialType,
|
ICredentialType,
|
||||||
INodeProperties,
|
INodeProperties,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
@@ -49,4 +51,18 @@ export class TheHiveApi implements ICredentialType {
|
|||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
authenticate: IAuthenticateGeneric = {
|
||||||
|
type: 'generic',
|
||||||
|
properties: {
|
||||||
|
headers: {
|
||||||
|
Authorization: '=Bearer {{$credentials.ApiKey}}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
test: ICredentialTestRequest = {
|
||||||
|
request: {
|
||||||
|
baseURL: '={{$credentials.url}}',
|
||||||
|
url: '/api/alert',
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
|
IAuthenticateGeneric,
|
||||||
|
ICredentialTestRequest,
|
||||||
ICredentialType,
|
ICredentialType,
|
||||||
INodeProperties,
|
INodeProperties,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
@@ -16,4 +18,19 @@ export class TypeformApi implements ICredentialType {
|
|||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
authenticate: IAuthenticateGeneric = {
|
||||||
|
type: 'generic',
|
||||||
|
properties: {
|
||||||
|
headers: {
|
||||||
|
Authorization: '=bearer {{$credentials.accessToken}}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
test: ICredentialTestRequest = {
|
||||||
|
request: {
|
||||||
|
baseURL: 'https://api.typeform.com',
|
||||||
|
url: '/forms',
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export class UrlScanIoApi implements ICredentialType {
|
|||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
authenticate = {
|
authenticate: IAuthenticateGeneric = {
|
||||||
type: 'generic',
|
type: 'generic',
|
||||||
properties: {
|
properties: {
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ export class WebflowApi implements ICredentialType {
|
|||||||
authenticate: IAuthenticateGeneric = {
|
authenticate: IAuthenticateGeneric = {
|
||||||
type: 'generic',
|
type: 'generic',
|
||||||
properties: {
|
properties: {
|
||||||
headers: {
|
headers:{
|
||||||
'Authorization': '=Bearer {{$credentials.accessToken}}',
|
Authorization: '=Bearer {{$credentials.accessToken}}',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import {
|
import {
|
||||||
|
ICredentialDataDecryptedObject,
|
||||||
|
ICredentialTestRequest,
|
||||||
ICredentialType,
|
ICredentialType,
|
||||||
|
IHttpRequestOptions,
|
||||||
INodeProperties,
|
INodeProperties,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
@@ -35,4 +38,22 @@ export class WooCommerceApi implements ICredentialType {
|
|||||||
description: 'Whether credentials should be included in the query. Occasionally, some servers may not parse the Authorization header correctly (if you see a “Consumer key is missing” error when authenticating over SSL, you have a server issue). In this case, you may provide the consumer key/secret as query string parameters instead.',
|
description: 'Whether credentials should be included in the query. Occasionally, some servers may not parse the Authorization header correctly (if you see a “Consumer key is missing” error when authenticating over SSL, you have a server issue). In this case, you may provide the consumer key/secret as query string parameters instead.',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
async authenticate(credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions> {
|
||||||
|
requestOptions.auth = {
|
||||||
|
// @ts-ignore
|
||||||
|
user: credentials.consumerKey as string,
|
||||||
|
password: credentials.consumerSecret as string,
|
||||||
|
};
|
||||||
|
if (credentials.includeCredentialsInQuery === true) {
|
||||||
|
delete requestOptions.auth;
|
||||||
|
Object.assign(requestOptions.qs, { consumer_key: credentials.consumerKey, consumer_secret: credentials.consumerSecret });
|
||||||
|
}
|
||||||
|
return requestOptions;
|
||||||
|
}
|
||||||
|
test: ICredentialTestRequest = {
|
||||||
|
request: {
|
||||||
|
baseURL: '={{$credentials.url}}/wp-json/wc/v3',
|
||||||
|
url: '/products/categories',
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { ICredentialType, INodeProperties } from 'n8n-workflow';
|
import { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
|
||||||
|
|
||||||
export class ZoomApi implements ICredentialType {
|
export class ZoomApi implements ICredentialType {
|
||||||
name = 'zoomApi';
|
name = 'zoomApi';
|
||||||
@@ -12,4 +12,18 @@ export class ZoomApi implements ICredentialType {
|
|||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
authenticate: IAuthenticateGeneric = {
|
||||||
|
type: 'generic',
|
||||||
|
properties: {
|
||||||
|
headers: {
|
||||||
|
Authorization: '=Bearer {{$credentials.accessToken}}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
test: ICredentialTestRequest = {
|
||||||
|
request: {
|
||||||
|
baseURL: 'https://api.zoom.us/v2',
|
||||||
|
url: '/users/me',
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ export async function activeCampaignApiRequest(this: IHookFunctions | IExecuteFu
|
|||||||
|
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {
|
||||||
'Api-Token': credentials.apiKey,
|
|
||||||
},
|
},
|
||||||
method,
|
method,
|
||||||
qs: query,
|
qs: query,
|
||||||
@@ -47,7 +46,7 @@ export async function activeCampaignApiRequest(this: IHookFunctions | IExecuteFu
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const responseData = await this.helpers.request!(options);
|
const responseData = await this.helpers.requestWithAuthentication.call(this, 'activeCampaignApi',options);
|
||||||
|
|
||||||
if (responseData.success === false) {
|
if (responseData.success === false) {
|
||||||
throw new NodeApiError(this.getNode(), responseData);
|
throw new NodeApiError(this.getNode(), responseData);
|
||||||
|
|||||||
@@ -15,13 +15,10 @@ export async function apiTemplateIoApiRequest(
|
|||||||
qs = {},
|
qs = {},
|
||||||
body = {},
|
body = {},
|
||||||
) {
|
) {
|
||||||
const { apiKey } = await this.getCredentials('apiTemplateIoApi') as { apiKey: string };
|
|
||||||
|
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {
|
||||||
'user-agent': 'n8n',
|
'user-agent': 'n8n',
|
||||||
Accept: 'application/json',
|
Accept: 'application/json',
|
||||||
'X-API-KEY': `${apiKey}`,
|
|
||||||
},
|
},
|
||||||
uri: `https://api.apitemplate.io/v1${endpoint}`,
|
uri: `https://api.apitemplate.io/v1${endpoint}`,
|
||||||
method,
|
method,
|
||||||
@@ -41,7 +38,7 @@ export async function apiTemplateIoApiRequest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await this.helpers.request!(options);
|
const response = await this.helpers.requestWithAuthentication.call(this, 'apiTemplateIoApi',options);
|
||||||
if (response.status === 'error') {
|
if (response.status === 'error') {
|
||||||
throw new NodeApiError(this.getNode(), response.message);
|
throw new NodeApiError(this.getNode(), response.message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,11 +33,7 @@ export async function clickupApiRequest(this: IHookFunctions | IExecuteFunctions
|
|||||||
const authenticationMethod = this.getNodeParameter('authentication', 0) as string;
|
const authenticationMethod = this.getNodeParameter('authentication', 0) as string;
|
||||||
|
|
||||||
if (authenticationMethod === 'accessToken') {
|
if (authenticationMethod === 'accessToken') {
|
||||||
|
return await this.helpers.requestWithAuthentication.call(this, 'clickUpApi', options);
|
||||||
const credentials = await this.getCredentials('clickUpApi');
|
|
||||||
|
|
||||||
options.headers!['Authorization'] = credentials.accessToken;
|
|
||||||
return await this.helpers.request!(options);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
const oAuth2Options: IOAuth2Options = {
|
const oAuth2Options: IOAuth2Options = {
|
||||||
|
|||||||
@@ -41,12 +41,7 @@ export async function dropboxApiRequest(this: IHookFunctions | IExecuteFunctions
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (authenticationMethod === 'accessToken') {
|
if (authenticationMethod === 'accessToken') {
|
||||||
|
return await this.helpers.requestWithAuthentication.call(this,'dropboxApi',options);
|
||||||
const credentials = await this.getCredentials('dropboxApi') as IDataObject;
|
|
||||||
|
|
||||||
options.headers!['Authorization'] = `Bearer ${credentials.accessToken}`;
|
|
||||||
|
|
||||||
return await this.helpers.request(options);
|
|
||||||
} else {
|
} else {
|
||||||
return await this.helpers.requestOAuth2.call(this, 'dropboxOAuth2Api', options);
|
return await this.helpers.requestOAuth2.call(this, 'dropboxOAuth2Api', options);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,10 +34,7 @@ export async function getresponseApiRequest(this: IWebhookFunctions | IHookFunct
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (authentication === 'apiKey') {
|
if (authentication === 'apiKey') {
|
||||||
const credentials = await this.getCredentials('getResponseApi');
|
return await this.helpers.requestWithAuthentication.call(this, 'getResponseApi', options);
|
||||||
options!.headers!['X-Auth-Token'] = `api-key ${credentials.apiKey}`;
|
|
||||||
//@ts-ignore
|
|
||||||
return await this.helpers.request.call(this, options);
|
|
||||||
} else {
|
} else {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
return await this.helpers.requestOAuth2.call(this, 'getResponseOAuth2Api', options);
|
return await this.helpers.requestOAuth2.call(this, 'getResponseOAuth2Api', options);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
IExecuteFunctions,
|
IExecuteFunctions,
|
||||||
IHookFunctions,
|
IHookFunctions,
|
||||||
ILoadOptionsFunctions,
|
|
||||||
} from 'n8n-core';
|
} from 'n8n-core';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -40,12 +39,8 @@ export async function gitlabApiRequest(this: IHookFunctions | IExecuteFunctions,
|
|||||||
try {
|
try {
|
||||||
if (authenticationMethod === 'accessToken') {
|
if (authenticationMethod === 'accessToken') {
|
||||||
const credentials = await this.getCredentials('gitlabApi');
|
const credentials = await this.getCredentials('gitlabApi');
|
||||||
|
|
||||||
options.headers!['Private-Token'] = `${credentials.accessToken}`;
|
|
||||||
|
|
||||||
options.uri = `${(credentials.server as string).replace(/\/$/, '')}/api/v4${endpoint}`;
|
options.uri = `${(credentials.server as string).replace(/\/$/, '')}/api/v4${endpoint}`;
|
||||||
|
return await this.helpers.requestWithAuthentication.call(this, 'gitlabApi', options);
|
||||||
return await this.helpers.request(options);
|
|
||||||
} else {
|
} else {
|
||||||
const credentials = await this.getCredentials('gitlabOAuth2Api');
|
const credentials = await this.getCredentials('gitlabOAuth2Api');
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ export async function grafanaApiRequest(
|
|||||||
qs: IDataObject = {},
|
qs: IDataObject = {},
|
||||||
) {
|
) {
|
||||||
const {
|
const {
|
||||||
apiKey,
|
|
||||||
baseUrl: rawBaseUrl,
|
baseUrl: rawBaseUrl,
|
||||||
} = await this.getCredentials('grafanaApi') as GrafanaCredentials;
|
} = await this.getCredentials('grafanaApi') as GrafanaCredentials;
|
||||||
|
|
||||||
@@ -33,7 +32,6 @@ export async function grafanaApiRequest(
|
|||||||
|
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${apiKey}`,
|
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
method,
|
method,
|
||||||
@@ -52,7 +50,7 @@ export async function grafanaApiRequest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await this.helpers.request!(options);
|
return await this.helpers.requestWithAuthentication.call(this, 'grafanaApi', options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error?.response?.data?.message === 'Team member not found') {
|
if (error?.response?.data?.message === 'Team member not found') {
|
||||||
error.response.data.message += '. Are you sure the user is a member of this team?';
|
error.response.data.message += '. Are you sure the user is a member of this team?';
|
||||||
@@ -108,4 +106,4 @@ export function deriveUid(this: IExecuteFunctions, uidOrUrl: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return uid;
|
return uid;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import {
|
|||||||
deriveUid,
|
deriveUid,
|
||||||
grafanaApiRequest,
|
grafanaApiRequest,
|
||||||
throwOnEmptyUpdate,
|
throwOnEmptyUpdate,
|
||||||
tolerateTrailingSlash,
|
|
||||||
} from './GenericFunctions';
|
} from './GenericFunctions';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -33,14 +32,9 @@ import {
|
|||||||
userOperations,
|
userOperations,
|
||||||
} from './descriptions';
|
} from './descriptions';
|
||||||
|
|
||||||
import {
|
|
||||||
OptionsWithUri,
|
|
||||||
} from 'request';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
DashboardUpdateFields,
|
DashboardUpdateFields,
|
||||||
DashboardUpdatePayload,
|
DashboardUpdatePayload,
|
||||||
GrafanaCredentials,
|
|
||||||
LoadedDashboards,
|
LoadedDashboards,
|
||||||
LoadedFolders,
|
LoadedFolders,
|
||||||
LoadedTeams,
|
LoadedTeams,
|
||||||
@@ -65,7 +59,6 @@ export class Grafana implements INodeType {
|
|||||||
{
|
{
|
||||||
name: 'grafanaApi',
|
name: 'grafanaApi',
|
||||||
required: true,
|
required: true,
|
||||||
testedBy: 'grafanaApiTest',
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
properties: [
|
properties: [
|
||||||
@@ -129,38 +122,6 @@ export class Grafana implements INodeType {
|
|||||||
return users.map(({ userId, email }) => ({ value: userId, name: email }));
|
return users.map(({ userId, email }) => ({ value: userId, name: email }));
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
credentialTest: {
|
|
||||||
async grafanaApiTest(
|
|
||||||
this: ICredentialTestFunctions,
|
|
||||||
credential: ICredentialsDecrypted,
|
|
||||||
): Promise<INodeCredentialTestResult> {
|
|
||||||
const { apiKey, baseUrl: rawBaseUrl } = credential.data as GrafanaCredentials;
|
|
||||||
const baseUrl = tolerateTrailingSlash(rawBaseUrl);
|
|
||||||
|
|
||||||
const options: OptionsWithUri = {
|
|
||||||
headers: {
|
|
||||||
Authorization: `Bearer ${apiKey}`,
|
|
||||||
},
|
|
||||||
method: 'GET',
|
|
||||||
uri: `${baseUrl}/api/folders`,
|
|
||||||
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<INodeExecutionData[][]> {
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||||
|
|||||||
@@ -36,17 +36,12 @@ export async function mailchimpApiRequest(this: IHookFunctions | IExecuteFunctio
|
|||||||
try {
|
try {
|
||||||
if (authenticationMethod === 'apiKey') {
|
if (authenticationMethod === 'apiKey') {
|
||||||
const credentials = await this.getCredentials('mailchimpApi');
|
const credentials = await this.getCredentials('mailchimpApi');
|
||||||
|
|
||||||
options.headers = Object.assign({}, headers, { Authorization: `apikey ${credentials.apiKey}` });
|
|
||||||
|
|
||||||
if (!(credentials.apiKey as string).includes('-')) {
|
if (!(credentials.apiKey as string).includes('-')) {
|
||||||
throw new NodeOperationError(this.getNode(), 'The API key is not valid!');
|
throw new NodeOperationError(this.getNode(), 'The API key is not valid!');
|
||||||
}
|
}
|
||||||
|
|
||||||
const datacenter = (credentials.apiKey as string).split('-').pop();
|
const datacenter = (credentials.apiKey as string).split('-').pop();
|
||||||
options.url = `https://${datacenter}.${host}${endpoint}`;
|
options.url = `https://${datacenter}.${host}${endpoint}`;
|
||||||
|
return await this.helpers.requestWithAuthentication.call(this, 'mailchimpApi', options);
|
||||||
return await this.helpers.request!(options);
|
|
||||||
} else {
|
} else {
|
||||||
const credentials = await this.getCredentials('mailchimpOAuth2Api');
|
const credentials = await this.getCredentials('mailchimpOAuth2Api');
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
import {
|
|
||||||
OptionsWithUri,
|
|
||||||
} from 'request';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IExecuteFunctions,
|
IExecuteFunctions,
|
||||||
IExecuteSingleFunctions,
|
IExecuteSingleFunctions,
|
||||||
@@ -10,12 +6,11 @@ import {
|
|||||||
} from 'n8n-core';
|
} from 'n8n-core';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ICredentialDataDecryptedObject,
|
|
||||||
ICredentialTestFunctions,
|
|
||||||
IDataObject,
|
IDataObject,
|
||||||
JsonObject,
|
JsonObject,
|
||||||
NodeApiError,
|
NodeApiError,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
|
import { OptionsWithUri } from 'request';
|
||||||
|
|
||||||
export async function mauticApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query?: IDataObject, uri?: string): Promise<any> { // tslint:disable-line:no-any
|
export async function mauticApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query?: IDataObject, uri?: string): Promise<any> { // tslint:disable-line:no-any
|
||||||
const authenticationMethod = this.getNodeParameter('authentication', 0, 'credentials') as string;
|
const authenticationMethod = this.getNodeParameter('authentication', 0, 'credentials') as string;
|
||||||
@@ -34,17 +29,8 @@ export async function mauticApiRequest(this: IHookFunctions | IExecuteFunctions
|
|||||||
let returnData;
|
let returnData;
|
||||||
|
|
||||||
if (authenticationMethod === 'credentials') {
|
if (authenticationMethod === 'credentials') {
|
||||||
const credentials = await this.getCredentials('mauticApi');
|
|
||||||
const baseUrl = credentials.url as string;
|
|
||||||
|
|
||||||
const base64Key = Buffer.from(`${credentials.username}:${credentials.password}`).toString('base64');
|
|
||||||
|
|
||||||
options.headers!.Authorization = `Basic ${base64Key}`;
|
|
||||||
|
|
||||||
options.uri = `${baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl}${options.uri}`;
|
|
||||||
|
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
returnData = await this.helpers.request(options);
|
returnData = await this.helpers.httpRequestWithAuthentication.call(this, 'mauticApi', options);
|
||||||
} else {
|
} else {
|
||||||
const credentials = await this.getCredentials('mauticOAuth2Api');
|
const credentials = await this.getCredentials('mauticOAuth2Api');
|
||||||
const baseUrl = credentials.url as string;
|
const baseUrl = credentials.url as string;
|
||||||
@@ -102,30 +88,3 @@ export function validateJSON(json: string | undefined): any { // tslint:disable-
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function validateCredentials(this: ICredentialTestFunctions, decryptedCredentials: ICredentialDataDecryptedObject): Promise<any> { // tslint:disable-line:no-any
|
|
||||||
const credentials = decryptedCredentials;
|
|
||||||
|
|
||||||
const {
|
|
||||||
url,
|
|
||||||
username,
|
|
||||||
password,
|
|
||||||
} = credentials as {
|
|
||||||
url: string,
|
|
||||||
username: string,
|
|
||||||
password: string,
|
|
||||||
};
|
|
||||||
|
|
||||||
const base64Key = Buffer.from(`${username}:${password}`).toString('base64');
|
|
||||||
|
|
||||||
const options: OptionsWithUri = {
|
|
||||||
method: 'GET',
|
|
||||||
headers: {
|
|
||||||
Authorization: `Basic ${base64Key}`,
|
|
||||||
},
|
|
||||||
uri: url.endsWith('/') ? `${url}api/users/self` : `${url}/api/users/self`,
|
|
||||||
json: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
return await this.helpers.request(options);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -3,12 +3,8 @@ import {
|
|||||||
} from 'n8n-core';
|
} from 'n8n-core';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ICredentialDataDecryptedObject,
|
|
||||||
ICredentialsDecrypted,
|
|
||||||
ICredentialTestFunctions,
|
|
||||||
IDataObject,
|
IDataObject,
|
||||||
ILoadOptionsFunctions,
|
ILoadOptionsFunctions,
|
||||||
INodeCredentialTestResult,
|
|
||||||
INodeExecutionData,
|
INodeExecutionData,
|
||||||
INodePropertyOptions,
|
INodePropertyOptions,
|
||||||
INodeType,
|
INodeType,
|
||||||
@@ -21,7 +17,6 @@ import {
|
|||||||
import {
|
import {
|
||||||
mauticApiRequest,
|
mauticApiRequest,
|
||||||
mauticApiRequestAllItems,
|
mauticApiRequestAllItems,
|
||||||
validateCredentials,
|
|
||||||
validateJSON,
|
validateJSON,
|
||||||
} from './GenericFunctions';
|
} from './GenericFunctions';
|
||||||
|
|
||||||
@@ -85,7 +80,6 @@ export class Mautic implements INodeType {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
testedBy: 'mauticCredentialTest',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'mauticOAuth2Api',
|
name: 'mauticOAuth2Api',
|
||||||
@@ -171,29 +165,6 @@ export class Mautic implements INodeType {
|
|||||||
};
|
};
|
||||||
|
|
||||||
methods = {
|
methods = {
|
||||||
credentialTest: {
|
|
||||||
async mauticCredentialTest(this: ICredentialTestFunctions, credential: ICredentialsDecrypted): Promise<INodeCredentialTestResult> {
|
|
||||||
try {
|
|
||||||
let responseData;
|
|
||||||
responseData = await validateCredentials.call(this, credential.data as ICredentialDataDecryptedObject);
|
|
||||||
if (responseData.id) {
|
|
||||||
return {
|
|
||||||
status: 'OK',
|
|
||||||
message: 'Authentication successful!',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
return {
|
|
||||||
status: 'Error',
|
|
||||||
message: 'Invalid credentials',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
status: 'Error',
|
|
||||||
message: 'Invalid credentials',
|
|
||||||
};
|
|
||||||
},
|
|
||||||
},
|
|
||||||
loadOptions: {
|
loadOptions: {
|
||||||
// Get all the available companies to display them to user so that he can
|
// Get all the available companies to display them to user so that he can
|
||||||
// select them easily
|
// select them easily
|
||||||
|
|||||||
@@ -39,9 +39,6 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa
|
|||||||
query = query || {};
|
query = query || {};
|
||||||
|
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
headers: {
|
|
||||||
'xc-auth': credentials.apiToken,
|
|
||||||
},
|
|
||||||
method,
|
method,
|
||||||
body,
|
body,
|
||||||
qs: query,
|
qs: query,
|
||||||
@@ -59,7 +56,7 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await this.helpers.request!(options);
|
return await this.helpers.requestWithAuthentication.call(this, 'nocodbApi', options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new NodeApiError(this.getNode(), error);
|
throw new NodeApiError(this.getNode(), error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -709,19 +709,6 @@ export function getConditions() {
|
|||||||
return elements;
|
return elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function validateCredentials(this: ICredentialTestFunctions, credentials: ICredentialDataDecryptedObject) {
|
|
||||||
const options: OptionsWithUri = {
|
|
||||||
headers: {
|
|
||||||
'Authorization': `Bearer ${credentials.apiKey}`,
|
|
||||||
'Notion-Version': apiVersion[2],
|
|
||||||
},
|
|
||||||
method: 'GET',
|
|
||||||
uri: `https://api.notion.com/v1/users/me`,
|
|
||||||
json: true,
|
|
||||||
};
|
|
||||||
return this.helpers.request!(options);
|
|
||||||
}
|
|
||||||
|
|
||||||
// tslint:disable-next-line: no-any
|
// tslint:disable-next-line: no-any
|
||||||
export async function downloadFiles(this: IExecuteFunctions | IPollFunctions, records: [{ properties: { [key: string]: any | { id: string, type: string, files: [{ external: { url: string } } | { file: { url: string } }] } } }]): Promise<INodeExecutionData[]> {
|
export async function downloadFiles(this: IExecuteFunctions | IPollFunctions, records: [{ properties: { [key: string]: any | { id: string, type: string, files: [{ external: { url: string } } | { file: { url: string } }] } } }]): Promise<INodeExecutionData[]> {
|
||||||
const elements: INodeExecutionData[] = [];
|
const elements: INodeExecutionData[] = [];
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ export class NotionTrigger implements INodeType {
|
|||||||
{
|
{
|
||||||
name: 'notionApi',
|
name: 'notionApi',
|
||||||
required: true,
|
required: true,
|
||||||
testedBy: 'notionApiCredentialTest',
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
polling: true,
|
polling: true,
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ import {
|
|||||||
notionApiRequest,
|
notionApiRequest,
|
||||||
notionApiRequestAllItems,
|
notionApiRequestAllItems,
|
||||||
simplifyObjects,
|
simplifyObjects,
|
||||||
validateCredentials,
|
|
||||||
validateJSON,
|
validateJSON,
|
||||||
} from '../GenericFunctions';
|
} from '../GenericFunctions';
|
||||||
|
|
||||||
@@ -195,23 +194,6 @@ export class NotionV2 implements INodeType {
|
|||||||
return returnData;
|
return returnData;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
credentialTest: {
|
|
||||||
async notionApiCredentialTest(this: ICredentialTestFunctions, credential: ICredentialsDecrypted): Promise<INodeCredentialTestResult> {
|
|
||||||
try {
|
|
||||||
await validateCredentials.call(this, credential.data as ICredentialDataDecryptedObject);
|
|
||||||
} catch (error) {
|
|
||||||
return {
|
|
||||||
status: 'Error',
|
|
||||||
message: 'The security token included in the request is invalid',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
status: 'OK',
|
|
||||||
message: 'Connection successful!',
|
|
||||||
};
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ export const versionDescription: INodeTypeDescription = {
|
|||||||
{
|
{
|
||||||
name: 'notionApi',
|
name: 'notionApi',
|
||||||
required: true,
|
required: true,
|
||||||
testedBy: 'notionApiCredentialTest',
|
|
||||||
// displayOptions: {
|
// displayOptions: {
|
||||||
// show: {
|
// show: {
|
||||||
// authentication: [
|
// authentication: [
|
||||||
|
|||||||
@@ -12,15 +12,8 @@ import { NodeApiError, NodeOperationError, } from 'n8n-workflow';
|
|||||||
export async function rocketchatApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions, resource: string, method: string, operation: string, body: any = {}, headers?: object): Promise<any> { // tslint:disable-line:no-any
|
export async function rocketchatApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions, resource: string, method: string, operation: string, body: any = {}, headers?: object): Promise<any> { // tslint:disable-line:no-any
|
||||||
const credentials = await this.getCredentials('rocketchatApi');
|
const credentials = await this.getCredentials('rocketchatApi');
|
||||||
|
|
||||||
const headerWithAuthentication = Object.assign({}, headers,
|
|
||||||
{
|
|
||||||
'X-Auth-Token': credentials.authKey,
|
|
||||||
'X-User-Id': credentials.userId,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
headers: headerWithAuthentication,
|
headers,
|
||||||
method,
|
method,
|
||||||
body,
|
body,
|
||||||
uri: `${credentials.domain}/api/v1${resource}.${operation}`,
|
uri: `${credentials.domain}/api/v1${resource}.${operation}`,
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import {
|
|||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
export async function sendGridApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, endpoint: string, method: string, body: any = {}, qs: IDataObject = {}, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
export async function sendGridApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, endpoint: string, method: string, body: any = {}, qs: IDataObject = {}, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||||
|
|
||||||
const host = 'api.sendgrid.com/v3';
|
const host = 'api.sendgrid.com/v3';
|
||||||
|
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
@@ -34,7 +33,6 @@ export async function sendGridApiRequest(this: IHookFunctions | IExecuteFunction
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//@ts-ignore
|
|
||||||
return await this.helpers.requestWithAuthentication.call(this, 'sendGridApi', options);
|
return await this.helpers.requestWithAuthentication.call(this, 'sendGridApi', options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new NodeApiError(this.getNode(), error);
|
throw new NodeApiError(this.getNode(), error);
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import {
|
|||||||
} from 'change-case';
|
} from 'change-case';
|
||||||
|
|
||||||
export async function shopifyApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
export async function shopifyApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||||
|
|
||||||
const authenticationMethod = this.getNodeParameter('authentication', 0, 'oAuth2') as string;
|
const authenticationMethod = this.getNodeParameter('authentication', 0, 'oAuth2') as string;
|
||||||
|
|
||||||
let credentials;
|
let credentials;
|
||||||
@@ -28,11 +27,9 @@ export async function shopifyApiRequest(this: IHookFunctions | IExecuteFunctions
|
|||||||
if (authenticationMethod === 'apiKey') {
|
if (authenticationMethod === 'apiKey') {
|
||||||
credentials = await this.getCredentials('shopifyApi');
|
credentials = await this.getCredentials('shopifyApi');
|
||||||
credentialType = 'shopifyApi';
|
credentialType = 'shopifyApi';
|
||||||
|
|
||||||
} else if (authenticationMethod === 'accessToken') {
|
} else if (authenticationMethod === 'accessToken') {
|
||||||
credentials = await this.getCredentials('shopifyAccessTokenApi');
|
credentials = await this.getCredentials('shopifyAccessTokenApi');
|
||||||
credentialType = 'shopifyAccessTokenApi';
|
credentialType = 'shopifyAccessTokenApi';
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
credentials = await this.getCredentials('shopifyOAuth2Api');
|
credentials = await this.getCredentials('shopifyOAuth2Api');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,12 +23,9 @@ import {
|
|||||||
* @returns {Promise<any>}
|
* @returns {Promise<any>}
|
||||||
*/
|
*/
|
||||||
export async function sms77ApiRequest(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: IDataObject, qs: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
export async function sms77ApiRequest(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: IDataObject, qs: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||||
const credentials = await this.getCredentials('sms77Api');
|
|
||||||
|
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {
|
||||||
SentWith: 'n8n',
|
SentWith: 'n8n',
|
||||||
'X-Api-Key': credentials.apiKey,
|
|
||||||
},
|
},
|
||||||
qs,
|
qs,
|
||||||
uri: `https://gateway.sms77.io/api${endpoint}`,
|
uri: `https://gateway.sms77.io/api${endpoint}`,
|
||||||
@@ -41,7 +38,7 @@ export async function sms77ApiRequest(this: IHookFunctions | IExecuteFunctions,
|
|||||||
body.json = 1;
|
body.json = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await this.helpers.request(options);
|
const response = await this.helpers.requestWithAuthentication.call(this, 'sms77Api', options);
|
||||||
|
|
||||||
if (response.success !== '100') {
|
if (response.success !== '100') {
|
||||||
throw new NodeApiError(this.getNode(), response, { message: 'Invalid sms77 credentials or API error!' });
|
throw new NodeApiError(this.getNode(), response, { message: 'Invalid sms77 credentials or API error!' });
|
||||||
|
|||||||
@@ -36,13 +36,9 @@ export async function stripeApiRequest(
|
|||||||
body: object,
|
body: object,
|
||||||
query?: object,
|
query?: object,
|
||||||
) {
|
) {
|
||||||
const credentials = await this.getCredentials('stripeApi');
|
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
method,
|
method,
|
||||||
auth: {
|
|
||||||
user: credentials.secretKey as string,
|
|
||||||
},
|
|
||||||
form: body,
|
form: body,
|
||||||
qs: query,
|
qs: query,
|
||||||
uri: `https://api.stripe.com/v1${endpoint}`,
|
uri: `https://api.stripe.com/v1${endpoint}`,
|
||||||
@@ -54,7 +50,7 @@ export async function stripeApiRequest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await this.helpers.request!.call(this, options);
|
return await this.helpers.requestWithAuthentication.call(this, 'stripeApi', options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new NodeApiError(this.getNode(), error);
|
throw new NodeApiError(this.getNode(), error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,10 +18,7 @@ import { Eq } from './QueryFunctions';
|
|||||||
export async function theHiveApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
export async function theHiveApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||||
const credentials = await this.getCredentials('theHiveApi');
|
const credentials = await this.getCredentials('theHiveApi');
|
||||||
|
|
||||||
const headerWithAuthentication = Object.assign({}, { Authorization: `Bearer ${credentials.ApiKey}` });
|
|
||||||
|
|
||||||
let options: OptionsWithUri = {
|
let options: OptionsWithUri = {
|
||||||
headers: headerWithAuthentication,
|
|
||||||
method,
|
method,
|
||||||
qs: query,
|
qs: query,
|
||||||
uri: uri || `${credentials.url}/api${resource}`,
|
uri: uri || `${credentials.url}/api${resource}`,
|
||||||
@@ -42,7 +39,7 @@ export async function theHiveApiRequest(this: IHookFunctions | IExecuteFunctions
|
|||||||
delete options.qs;
|
delete options.qs;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return await this.helpers.request!(options);
|
return await this.helpers.requestWithAuthentication.call(this, 'theHiveApi',options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new NodeApiError(this.getNode(), error);
|
throw new NodeApiError(this.getNode(), error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,12 +64,7 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (authenticationMethod === 'accessToken') {
|
if (authenticationMethod === 'accessToken') {
|
||||||
|
return await this.helpers.requestWithAuthentication.call(this, 'typeformApi',options);
|
||||||
const credentials = await this.getCredentials('typeformApi');
|
|
||||||
|
|
||||||
options.headers!['Authorization'] = `bearer ${credentials.accessToken}`;
|
|
||||||
|
|
||||||
return await this.helpers.request!(options);
|
|
||||||
} else {
|
} else {
|
||||||
return await this.helpers.requestOAuth2!.call(this, 'typeformOAuth2Api', options);
|
return await this.helpers.requestOAuth2!.call(this, 'typeformOAuth2Api', options);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ export async function urlScanIoApiRequest(
|
|||||||
body: IDataObject = {},
|
body: IDataObject = {},
|
||||||
qs: IDataObject = {},
|
qs: IDataObject = {},
|
||||||
) {
|
) {
|
||||||
|
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
method,
|
method,
|
||||||
body,
|
body,
|
||||||
@@ -36,7 +35,7 @@ export async function urlScanIoApiRequest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await this.helpers.request(options);
|
return await this.helpers.requestWithAuthentication.call(this, 'urlScanIoApi',options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new NodeApiError(this.getNode(), error);
|
throw new NodeApiError(this.getNode(), error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,7 @@ import {
|
|||||||
} from 'n8n-core';
|
} from 'n8n-core';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ICredentialsDecrypted,
|
|
||||||
ICredentialTestFunctions,
|
|
||||||
IDataObject,
|
IDataObject,
|
||||||
INodeCredentialTestResult,
|
|
||||||
INodeExecutionData,
|
INodeExecutionData,
|
||||||
INodeType,
|
INodeType,
|
||||||
INodeTypeDescription,
|
INodeTypeDescription,
|
||||||
|
|||||||
@@ -40,27 +40,19 @@ export async function woocommerceApiRequest(this: IHookFunctions | IExecuteFunct
|
|||||||
const credentials = await this.getCredentials('wooCommerceApi');
|
const credentials = await this.getCredentials('wooCommerceApi');
|
||||||
|
|
||||||
let options: OptionsWithUri = {
|
let options: OptionsWithUri = {
|
||||||
auth: {
|
|
||||||
user: credentials.consumerKey as string,
|
|
||||||
password: credentials.consumerSecret as string,
|
|
||||||
},
|
|
||||||
method,
|
method,
|
||||||
qs,
|
qs,
|
||||||
body,
|
body,
|
||||||
uri: uri || `${credentials.url}/wp-json/wc/v3${resource}`,
|
uri: uri || `${credentials.url}/wp-json/wc/v3${resource}`,
|
||||||
json: true,
|
json: true,
|
||||||
};
|
};
|
||||||
if (credentials.includeCredentialsInQuery === true) {
|
|
||||||
delete options.auth;
|
|
||||||
Object.assign(qs, { consumer_key: credentials.consumerKey, consumer_secret: credentials.consumerSecret });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Object.keys(body).length) {
|
if (!Object.keys(body).length) {
|
||||||
delete options.form;
|
delete options.form;
|
||||||
}
|
}
|
||||||
options = Object.assign({}, options, option);
|
options = Object.assign({}, options, option);
|
||||||
try {
|
try {
|
||||||
return await this.helpers.request!(options);
|
return await this.helpers.requestWithAuthentication.call(this,'wooCommerceApi', options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new NodeApiError(this.getNode(), error);
|
throw new NodeApiError(this.getNode(), error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,11 +36,7 @@ export async function zoomApiRequest(this: IExecuteFunctions | IExecuteSingleFun
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (authenticationMethod === 'accessToken') {
|
if (authenticationMethod === 'accessToken') {
|
||||||
const credentials = await this.getCredentials('zoomApi');
|
return await this.helpers.requestWithAuthentication.call(this,'zoomApi',options);
|
||||||
options.headers!.Authorization = `Bearer ${credentials.accessToken}`;
|
|
||||||
|
|
||||||
//@ts-ignore
|
|
||||||
return await this.helpers.request(options);
|
|
||||||
} else {
|
} else {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
return await this.helpers.requestOAuth2.call(this, 'zoomOAuth2Api', options);
|
return await this.helpers.requestOAuth2.call(this, 'zoomOAuth2Api', options);
|
||||||
|
|||||||
Reference in New Issue
Block a user