Skip to content

Commit

Permalink
fix(HTTP Request Node): Make all OAuth2 credentials work with HTTP Re…
Browse files Browse the repository at this point in the history
…quest Node (#3503)
  • Loading branch information
ivov authored Jun 26, 2022
1 parent 7879239 commit acdb4d9
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion packages/nodes-base/nodes/HttpRequest/HttpRequest.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
INodeExecutionData,
INodeType,
INodeTypeDescription,
IOAuth2Options,
NodeApiError,
NodeOperationError,
} from 'n8n-workflow';
Expand Down Expand Up @@ -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 },
),
);
}
}
Expand Down

0 comments on commit acdb4d9

Please sign in to comment.