From acdb4d92c8ef95646e69694b2451a9111a81c52f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Sun, 26 Jun 2022 06:14:08 +0200 Subject: [PATCH] fix(HTTP Request Node): Make all OAuth2 credentials work with HTTP Request Node (#3503) --- .../nodes/HttpRequest/HttpRequest.node.ts | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/HttpRequest/HttpRequest.node.ts b/packages/nodes-base/nodes/HttpRequest/HttpRequest.node.ts index d826bc66d16af..b19453870cd29 100644 --- a/packages/nodes-base/nodes/HttpRequest/HttpRequest.node.ts +++ b/packages/nodes-base/nodes/HttpRequest/HttpRequest.node.ts @@ -7,6 +7,7 @@ import { INodeExecutionData, INodeType, INodeTypeDescription, + IOAuth2Options, NodeApiError, NodeOperationError, } from 'n8n-workflow'; @@ -1202,9 +1203,31 @@ export class HttpRequest implements INodeType { ); } } else if (authentication === 'predefinedCredentialType' && nodeCredentialType) { + + const oAuth2Options: { [credentialType: string]: IOAuth2Options } = { + clickUpOAuth2Api: { + keepBearer: false, + tokenType: 'Bearer', + }, + slackOAuth2Api: { + tokenType: 'Bearer', + property: 'authed_user.access_token', + }, + boxOAuth2Api: { + includeCredentialsOnRefreshOnBody: true, + }, + }; + + const additionalOAuth2Options = oAuth2Options[nodeCredentialType]; + // service-specific cred: OAuth1, OAuth2, plain requestPromises.push( - this.helpers.requestWithAuthentication.call(this, nodeCredentialType, requestOptions), + this.helpers.requestWithAuthentication.call( + this, + nodeCredentialType, + requestOptions, + additionalOAuth2Options && { oauth2: additionalOAuth2Options }, + ), ); } }