mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
feat(Webflow Trigger Node): Reduce chance of webhook duplication and add credential test (#3594)
* upstream merge * ⚡ additional check for webhook, credentials update * 🔥 Remove unnecessary condition * ⚡ Change credential injection to generic type * 👕 Fix linting issue Co-authored-by: ricardo <ricardoespinoza105@gmail.com>
This commit is contained in:
@@ -12,7 +12,6 @@ import {
|
||||
import {
|
||||
IDataObject,
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function webflowApiRequest(
|
||||
@@ -24,7 +23,17 @@ export async function webflowApiRequest(
|
||||
uri?: string,
|
||||
option: IDataObject = {},
|
||||
) {
|
||||
const authenticationMethod = this.getNodeParameter('authentication', 0);
|
||||
const authenticationMethod = this.getNodeParameter('authentication', 0, 'accessToken');
|
||||
let credentialsType = '';
|
||||
|
||||
if (authenticationMethod === 'accessToken') {
|
||||
credentialsType = 'webflowApi';
|
||||
}
|
||||
|
||||
if (authenticationMethod === 'oAuth2') {
|
||||
credentialsType = 'webflowOAuth2Api';
|
||||
}
|
||||
|
||||
|
||||
let options: OptionsWithUri = {
|
||||
headers: {
|
||||
@@ -46,15 +55,7 @@ export async function webflowApiRequest(
|
||||
delete options.body;
|
||||
}
|
||||
try {
|
||||
if (authenticationMethod === 'accessToken') {
|
||||
const credentials = await this.getCredentials('webflowApi');
|
||||
|
||||
options.headers!['authorization'] = `Bearer ${credentials.accessToken}`;
|
||||
|
||||
return await this.helpers.request!(options);
|
||||
} else {
|
||||
return await this.helpers.requestOAuth2!.call(this, 'webflowOAuth2Api', options);
|
||||
}
|
||||
return await this.helpers.requestWithAuthentication.call(this, credentialsType, options);
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user