mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 21:07:28 -08:00
N8N-4126 credentials injection and testing on specific nodes (#3816)
* Add credential injection and testing to Lemlist, Uproc, Supabase, Segment, Phantombuster, Mailgun and Dropcontact
This commit is contained in:
parent
5285fc1de6
commit
76f9ad8bae
|
@ -1,4 +1,9 @@
|
||||||
import { ICredentialType, NodePropertyTypes } from 'n8n-workflow';
|
import {
|
||||||
|
IAuthenticateGeneric,
|
||||||
|
ICredentialTestRequest,
|
||||||
|
ICredentialType,
|
||||||
|
NodePropertyTypes,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
export class DropcontactApi implements ICredentialType {
|
export class DropcontactApi implements ICredentialType {
|
||||||
name = 'dropcontactApi';
|
name = 'dropcontactApi';
|
||||||
|
@ -12,4 +17,23 @@ export class DropcontactApi implements ICredentialType {
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
authenticate: IAuthenticateGeneric = {
|
||||||
|
type: 'generic',
|
||||||
|
properties: {
|
||||||
|
headers: {
|
||||||
|
'user-agent': 'n8n',
|
||||||
|
'X-Access-Token': '={{$credentials.apiKey}}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
test: ICredentialTestRequest = {
|
||||||
|
request: {
|
||||||
|
baseURL: 'https://api.dropcontact.io',
|
||||||
|
url: '/batch',
|
||||||
|
method: 'POST',
|
||||||
|
body: {
|
||||||
|
data: [{ email: '' }],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
import { ICredentialType, INodeProperties } from 'n8n-workflow';
|
import {
|
||||||
|
ICredentialDataDecryptedObject,
|
||||||
|
ICredentialTestRequest,
|
||||||
|
ICredentialType,
|
||||||
|
IHttpRequestOptions,
|
||||||
|
INodeProperties,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
export class LemlistApi implements ICredentialType {
|
export class LemlistApi implements ICredentialType {
|
||||||
name = 'lemlistApi';
|
name = 'lemlistApi';
|
||||||
|
@ -12,4 +18,19 @@ export class LemlistApi implements ICredentialType {
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
async authenticate(
|
||||||
|
credentials: ICredentialDataDecryptedObject,
|
||||||
|
requestOptions: IHttpRequestOptions,
|
||||||
|
): Promise<IHttpRequestOptions> {
|
||||||
|
const encodedApiKey = Buffer.from(':' + credentials.apiKey).toString('base64');
|
||||||
|
requestOptions.headers!['Authorization'] = `Basic ${encodedApiKey}`;
|
||||||
|
requestOptions.headers!['user-agent'] = 'n8n';
|
||||||
|
return requestOptions;
|
||||||
|
}
|
||||||
|
test: ICredentialTestRequest = {
|
||||||
|
request: {
|
||||||
|
baseURL: 'https://api.lemlist.com/api',
|
||||||
|
url: '/campaigns',
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
import { ICredentialType, INodeProperties } from 'n8n-workflow';
|
import {
|
||||||
|
IAuthenticateGeneric,
|
||||||
|
ICredentialTestRequest,
|
||||||
|
ICredentialType,
|
||||||
|
INodeProperties,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
export class MailgunApi implements ICredentialType {
|
export class MailgunApi implements ICredentialType {
|
||||||
name = 'mailgunApi';
|
name = 'mailgunApi';
|
||||||
|
@ -35,4 +40,19 @@ export class MailgunApi implements ICredentialType {
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
authenticate: IAuthenticateGeneric = {
|
||||||
|
type: 'generic',
|
||||||
|
properties: {
|
||||||
|
auth: {
|
||||||
|
username: 'api',
|
||||||
|
password: '={{$credentials.apiKey}}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
test: ICredentialTestRequest = {
|
||||||
|
request: {
|
||||||
|
baseURL: '=https://{{$credentials.apiDomain}}/v3',
|
||||||
|
url: '/domains',
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
import { ICredentialType, INodeProperties } from 'n8n-workflow';
|
import {
|
||||||
|
IAuthenticateGeneric,
|
||||||
|
ICredentialTestRequest,
|
||||||
|
ICredentialType,
|
||||||
|
INodeProperties,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
export class PhantombusterApi implements ICredentialType {
|
export class PhantombusterApi implements ICredentialType {
|
||||||
name = 'phantombusterApi';
|
name = 'phantombusterApi';
|
||||||
|
@ -12,4 +17,18 @@ export class PhantombusterApi implements ICredentialType {
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
authenticate: IAuthenticateGeneric = {
|
||||||
|
type: 'generic',
|
||||||
|
properties: {
|
||||||
|
headers: {
|
||||||
|
'X-Phantombuster-Key': '={{$credentials.apiKey}}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
test: ICredentialTestRequest = {
|
||||||
|
request: {
|
||||||
|
baseURL: 'https://api.phantombuster.com/api/v2',
|
||||||
|
url: '/agents/fetch-all',
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
import { ICredentialType, INodeProperties } from 'n8n-workflow';
|
import {
|
||||||
|
ICredentialDataDecryptedObject,
|
||||||
|
ICredentialType,
|
||||||
|
IHttpRequestOptions,
|
||||||
|
INodeProperties,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
export class SegmentApi implements ICredentialType {
|
export class SegmentApi implements ICredentialType {
|
||||||
name = 'segmentApi';
|
name = 'segmentApi';
|
||||||
|
@ -12,4 +17,12 @@ export class SegmentApi implements ICredentialType {
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
async authenticate(
|
||||||
|
credentials: ICredentialDataDecryptedObject,
|
||||||
|
requestOptions: IHttpRequestOptions,
|
||||||
|
): Promise<IHttpRequestOptions> {
|
||||||
|
const base64Key = Buffer.from(`${credentials.writekey}:`).toString('base64');
|
||||||
|
requestOptions.headers!['Authorization'] = `Basic ${base64Key}`;
|
||||||
|
return requestOptions;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
import { ICredentialType, INodeProperties } from 'n8n-workflow';
|
import {
|
||||||
|
IAuthenticateGeneric,
|
||||||
|
ICredentialTestRequest,
|
||||||
|
ICredentialType,
|
||||||
|
INodeProperties,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
export class SupabaseApi implements ICredentialType {
|
export class SupabaseApi implements ICredentialType {
|
||||||
name = 'supabaseApi';
|
name = 'supabaseApi';
|
||||||
|
@ -19,4 +24,22 @@ export class SupabaseApi implements ICredentialType {
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
authenticate: IAuthenticateGeneric = {
|
||||||
|
type: 'generic',
|
||||||
|
properties: {
|
||||||
|
headers: {
|
||||||
|
apikey: '={{$credentials.serviceRole}}',
|
||||||
|
Authorization: '=Bearer {{$credentials.serviceRole}}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
test: ICredentialTestRequest = {
|
||||||
|
request: {
|
||||||
|
baseURL: '={{$credentials.host}}/rest/v1',
|
||||||
|
headers: {
|
||||||
|
Prefer: 'return=representation',
|
||||||
|
},
|
||||||
|
url: '/',
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
import { ICredentialType, INodeProperties } from 'n8n-workflow';
|
import {
|
||||||
|
ICredentialDataDecryptedObject,
|
||||||
|
ICredentialTestRequest,
|
||||||
|
ICredentialType,
|
||||||
|
IHttpRequestOptions,
|
||||||
|
INodeProperties,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
export class UProcApi implements ICredentialType {
|
export class UProcApi implements ICredentialType {
|
||||||
name = 'uprocApi';
|
name = 'uprocApi';
|
||||||
|
@ -19,4 +25,22 @@ export class UProcApi implements ICredentialType {
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
async authenticate(
|
||||||
|
credentials: ICredentialDataDecryptedObject,
|
||||||
|
requestOptions: IHttpRequestOptions,
|
||||||
|
): Promise<IHttpRequestOptions> {
|
||||||
|
const token = Buffer.from(`${credentials.email}:${credentials.apiKey}`).toString('base64');
|
||||||
|
requestOptions.headers = {
|
||||||
|
...requestOptions.headers,
|
||||||
|
Authorization: `Basic ${token}`,
|
||||||
|
};
|
||||||
|
return requestOptions;
|
||||||
|
}
|
||||||
|
test: ICredentialTestRequest = {
|
||||||
|
request: {
|
||||||
|
baseURL: 'https://api.uproc.io/api/v2',
|
||||||
|
url: '/profile',
|
||||||
|
method: 'GET',
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import {
|
||||||
NodeApiError,
|
NodeApiError,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
import { dropcontactApiRequest, validateCredentials } from './GenericFunction';
|
import { dropcontactApiRequest } from './GenericFunction';
|
||||||
|
|
||||||
export class Dropcontact implements INodeType {
|
export class Dropcontact implements INodeType {
|
||||||
description: INodeTypeDescription = {
|
description: INodeTypeDescription = {
|
||||||
|
@ -32,7 +32,6 @@ export class Dropcontact implements INodeType {
|
||||||
{
|
{
|
||||||
name: 'dropcontactApi',
|
name: 'dropcontactApi',
|
||||||
required: true,
|
required: true,
|
||||||
testedBy: 'dropcontactApiCredentialTest',
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
properties: [
|
properties: [
|
||||||
|
@ -244,30 +243,6 @@ export class Dropcontact implements INodeType {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
methods = {
|
|
||||||
credentialTest: {
|
|
||||||
async dropcontactApiCredentialTest(
|
|
||||||
this: ICredentialTestFunctions,
|
|
||||||
credential: ICredentialsDecrypted,
|
|
||||||
): Promise<INodeCredentialTestResult> {
|
|
||||||
try {
|
|
||||||
await validateCredentials.call(this, credential.data as ICredentialDataDecryptedObject);
|
|
||||||
} catch (error) {
|
|
||||||
return {
|
|
||||||
status: 'Error',
|
|
||||||
message: 'The API Key included in the request is invalid',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
status: 'OK',
|
|
||||||
message: 'Connection successful!',
|
|
||||||
};
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||||
const entryData = this.getInputData();
|
const entryData = this.getInputData();
|
||||||
const resource = this.getNodeParameter('resource', 0) as string;
|
const resource = this.getNodeParameter('resource', 0) as string;
|
||||||
|
|
|
@ -1,12 +1,6 @@
|
||||||
import { IExecuteFunctions, IHookFunctions } from 'n8n-core';
|
import { IExecuteFunctions, IHookFunctions } from 'n8n-core';
|
||||||
|
|
||||||
import {
|
import { IDataObject, ILoadOptionsFunctions, NodeApiError } from 'n8n-workflow';
|
||||||
ICredentialDataDecryptedObject,
|
|
||||||
ICredentialTestFunctions,
|
|
||||||
IDataObject,
|
|
||||||
ILoadOptionsFunctions,
|
|
||||||
NodeApiError,
|
|
||||||
} from 'n8n-workflow';
|
|
||||||
|
|
||||||
import { OptionsWithUri } from 'request';
|
import { OptionsWithUri } from 'request';
|
||||||
|
|
||||||
|
@ -20,15 +14,7 @@ export async function dropcontactApiRequest(
|
||||||
body: IDataObject,
|
body: IDataObject,
|
||||||
qs: IDataObject,
|
qs: IDataObject,
|
||||||
) {
|
) {
|
||||||
const { apiKey } = (await this.getCredentials('dropcontactApi')) as {
|
|
||||||
apiKey: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
headers: {
|
|
||||||
'user-agent': 'n8n',
|
|
||||||
'X-Access-Token': apiKey,
|
|
||||||
},
|
|
||||||
method,
|
method,
|
||||||
uri: `https://api.dropcontact.io${endpoint}`,
|
uri: `https://api.dropcontact.io${endpoint}`,
|
||||||
qs,
|
qs,
|
||||||
|
@ -45,35 +31,8 @@ export async function dropcontactApiRequest(
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await this.helpers.request!(options);
|
return await this.helpers.requestWithAuthentication.call(this, 'dropcontactApi', options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new NodeApiError(this.getNode(), error);
|
throw new NodeApiError(this.getNode(), error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function validateCredentials(
|
|
||||||
this: ICredentialTestFunctions,
|
|
||||||
decryptedCredentials: ICredentialDataDecryptedObject,
|
|
||||||
// tslint:disable-next-line:no-any
|
|
||||||
): Promise<any> {
|
|
||||||
const credentials = decryptedCredentials;
|
|
||||||
|
|
||||||
const { apiKey } = credentials as {
|
|
||||||
apiKey: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
const options: OptionsWithUri = {
|
|
||||||
headers: {
|
|
||||||
'user-agent': 'n8n',
|
|
||||||
'X-Access-Token': apiKey,
|
|
||||||
},
|
|
||||||
method: 'POST',
|
|
||||||
body: {
|
|
||||||
data: [{ email: '' }],
|
|
||||||
},
|
|
||||||
uri: `https://api.dropcontact.io/batch`,
|
|
||||||
json: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
return this.helpers.request!(options);
|
|
||||||
}
|
|
||||||
|
|
|
@ -17,16 +17,9 @@ export async function lemlistApiRequest(
|
||||||
qs: IDataObject = {},
|
qs: IDataObject = {},
|
||||||
option: IDataObject = {},
|
option: IDataObject = {},
|
||||||
) {
|
) {
|
||||||
const { apiKey } = (await this.getCredentials('lemlistApi')) as {
|
|
||||||
apiKey: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
const encodedApiKey = Buffer.from(':' + apiKey).toString('base64');
|
|
||||||
|
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {
|
||||||
'user-agent': 'n8n',
|
|
||||||
Authorization: `Basic ${encodedApiKey}`,
|
|
||||||
},
|
},
|
||||||
method,
|
method,
|
||||||
uri: `https://api.lemlist.com/api${endpoint}`,
|
uri: `https://api.lemlist.com/api${endpoint}`,
|
||||||
|
@ -48,7 +41,7 @@ export async function lemlistApiRequest(
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await this.helpers.request!(options);
|
return await this.helpers.requestWithAuthentication.call(this,'lemlistApi',options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new NodeApiError(this.getNode(), error);
|
throw new NodeApiError(this.getNode(), error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,17 +173,13 @@ export class Mailgun implements INodeType {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
formData,
|
formData,
|
||||||
uri: `https://${credentials.apiDomain}/v3/${credentials.emailDomain}/messages`,
|
uri: `https://${credentials.apiDomain}/v3/${credentials.emailDomain}/messages`,
|
||||||
auth: {
|
|
||||||
user: 'api',
|
|
||||||
pass: credentials.apiKey as string,
|
|
||||||
},
|
|
||||||
json: true,
|
json: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
let responseData;
|
let responseData;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
responseData = await this.helpers.request(options);
|
responseData = await this.helpers.requestWithAuthentication.call(this, 'mailgunApi', options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new NodeApiError(this.getNode(), error);
|
throw new NodeApiError(this.getNode(), error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ export async function phantombusterApiRequest(
|
||||||
|
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {
|
||||||
'X-Phantombuster-Key': credentials.apiKey,
|
|
||||||
},
|
},
|
||||||
method,
|
method,
|
||||||
body,
|
body,
|
||||||
|
@ -31,7 +30,7 @@ export async function phantombusterApiRequest(
|
||||||
delete options.body;
|
delete options.body;
|
||||||
}
|
}
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
return await this.helpers.request.call(this, options);
|
return await this.helpers.requestWithAuthentication.call(this, 'phantombusterApi',options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new NodeApiError(this.getNode(), error);
|
throw new NodeApiError(this.getNode(), error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,18 +17,14 @@ export async function segmentApiRequest(
|
||||||
| IWebhookFunctions,
|
| IWebhookFunctions,
|
||||||
method: string,
|
method: string,
|
||||||
resource: string,
|
resource: string,
|
||||||
// tslint:disable-next-line:no-any
|
body: any = {}, // tslint:disable-line:no-any
|
||||||
body: any = {},
|
|
||||||
qs: IDataObject = {},
|
qs: IDataObject = {},
|
||||||
uri?: string,
|
uri?: string,
|
||||||
option: IDataObject = {},
|
option: IDataObject = {},
|
||||||
// tslint:disable-next-line:no-any
|
// tslint:disable-next-line:no-any
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
const credentials = await this.getCredentials('segmentApi');
|
|
||||||
const base64Key = Buffer.from(`${credentials.writekey}:`).toString('base64');
|
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Basic ${base64Key}`,
|
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
method,
|
method,
|
||||||
|
@ -41,7 +37,7 @@ export async function segmentApiRequest(
|
||||||
delete options.body;
|
delete options.body;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return await this.helpers.request!(options);
|
return await this.helpers.requestWithAuthentication.call(this, 'segmentApi', options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new NodeApiError(this.getNode(), error);
|
throw new NodeApiError(this.getNode(), error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,6 @@ export async function supabaseApiRequest(
|
||||||
|
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {
|
||||||
apikey: credentials.serviceRole,
|
|
||||||
Authorization: 'Bearer ' + credentials.serviceRole,
|
|
||||||
Prefer: 'return=representation',
|
Prefer: 'return=representation',
|
||||||
},
|
},
|
||||||
method,
|
method,
|
||||||
|
@ -56,8 +54,8 @@ export async function supabaseApiRequest(
|
||||||
if (Object.keys(body).length === 0) {
|
if (Object.keys(body).length === 0) {
|
||||||
delete options.body;
|
delete options.body;
|
||||||
}
|
}
|
||||||
//@ts-ignore
|
return await this.helpers.requestWithAuthentication.call(this, 'supabaseApi', options);
|
||||||
return await this.helpers?.request(options);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new NodeApiError(this.getNode(), error);
|
throw new NodeApiError(this.getNode(), error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,34 +7,27 @@ import {
|
||||||
ILoadOptionsFunctions,
|
ILoadOptionsFunctions,
|
||||||
} from 'n8n-core';
|
} from 'n8n-core';
|
||||||
|
|
||||||
import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow';
|
import { IDataObject, IHttpRequestMethods, IHttpRequestOptions, NodeApiError } from 'n8n-workflow';
|
||||||
|
|
||||||
export async function uprocApiRequest(
|
export async function uprocApiRequest(
|
||||||
this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions,
|
this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions,
|
||||||
method: string,
|
method: string,
|
||||||
// tslint:disable-next-line:no-any
|
body: any = {}, // tslint:disable-line:no-any
|
||||||
body: any = {},
|
|
||||||
qs: IDataObject = {},
|
qs: IDataObject = {},
|
||||||
uri?: string,
|
uri?: string,
|
||||||
option: IDataObject = {},
|
option: IDataObject = {},
|
||||||
// tslint:disable-next-line:no-any
|
// tslint:disable-next-line:no-any
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
const credentials = await this.getCredentials('uprocApi');
|
const options: IHttpRequestOptions = {
|
||||||
const token = Buffer.from(`${credentials.email}:${credentials.apiKey}`).toString('base64');
|
method: method as IHttpRequestMethods,
|
||||||
const options: OptionsWithUri = {
|
|
||||||
headers: {
|
|
||||||
Authorization: `Basic ${token}`,
|
|
||||||
'User-agent': 'n8n',
|
|
||||||
},
|
|
||||||
method,
|
|
||||||
qs,
|
qs,
|
||||||
body,
|
body,
|
||||||
uri: uri || `https://api.uproc.io/api/v2/process`,
|
url: 'https://api.uproc.io/api/v2/process',
|
||||||
json: true,
|
json: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await this.helpers.request!(options);
|
return await this.helpers.httpRequestWithAuthentication.call(this, 'uprocApi', options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new NodeApiError(this.getNode(), error);
|
throw new NodeApiError(this.getNode(), error);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue