mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
⚡ Add OAuth2 authentication to Pipedrive Trigger Node
This commit is contained in:
parent
86d19fb11f
commit
1630d20e39
|
@ -54,13 +54,31 @@ export class PipedriveTrigger implements INodeType {
|
||||||
{
|
{
|
||||||
name: 'pipedriveApi',
|
name: 'pipedriveApi',
|
||||||
required: true,
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
authentication: [
|
||||||
|
'apiToken',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'pipedriveOAuth2Api',
|
||||||
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
authentication: [
|
||||||
|
'oAuth2',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'httpBasicAuth',
|
name: 'httpBasicAuth',
|
||||||
required: true,
|
required: true,
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
authentication: [
|
incomingAuthentication: [
|
||||||
'basicAuth',
|
'basicAuth',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -80,6 +98,23 @@ export class PipedriveTrigger implements INodeType {
|
||||||
displayName: 'Authentication',
|
displayName: 'Authentication',
|
||||||
name: 'authentication',
|
name: 'authentication',
|
||||||
type: 'options',
|
type: 'options',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'API Token',
|
||||||
|
value: 'apiToken',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'OAuth2',
|
||||||
|
value: 'oAuth2',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
default: 'apiToken',
|
||||||
|
description: 'Method of authentication.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Incoming Authentication',
|
||||||
|
name: 'incomingAuthentication',
|
||||||
|
type: 'options',
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
name: 'Basic Auth',
|
name: 'Basic Auth',
|
||||||
|
@ -91,7 +126,7 @@ export class PipedriveTrigger implements INodeType {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
default: 'none',
|
default: 'none',
|
||||||
description: 'If authentication should be activated for the webhook (makes it more scure).',
|
description: 'If authentication should be activated for the webhook (makes it more secure).',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Action',
|
displayName: 'Action',
|
||||||
|
@ -218,7 +253,7 @@ export class PipedriveTrigger implements INodeType {
|
||||||
},
|
},
|
||||||
async create(this: IHookFunctions): Promise<boolean> {
|
async create(this: IHookFunctions): Promise<boolean> {
|
||||||
const webhookUrl = this.getNodeWebhookUrl('default');
|
const webhookUrl = this.getNodeWebhookUrl('default');
|
||||||
const authentication = this.getNodeParameter('authentication', 0) as string;
|
const incomingAuthentication = this.getNodeParameter('incomingAuthentication', 0) as string;
|
||||||
const eventAction = this.getNodeParameter('action') as string;
|
const eventAction = this.getNodeParameter('action') as string;
|
||||||
const eventObject = this.getNodeParameter('object') as string;
|
const eventObject = this.getNodeParameter('object') as string;
|
||||||
|
|
||||||
|
@ -232,7 +267,7 @@ export class PipedriveTrigger implements INodeType {
|
||||||
http_auth_password: undefined as string | undefined,
|
http_auth_password: undefined as string | undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (authentication === 'basicAuth') {
|
if (incomingAuthentication === 'basicAuth') {
|
||||||
const httpBasicAuth = this.getCredentials('httpBasicAuth');
|
const httpBasicAuth = this.getCredentials('httpBasicAuth');
|
||||||
|
|
||||||
if (httpBasicAuth === undefined || !httpBasicAuth.user || !httpBasicAuth.password) {
|
if (httpBasicAuth === undefined || !httpBasicAuth.user || !httpBasicAuth.password) {
|
||||||
|
@ -285,9 +320,9 @@ export class PipedriveTrigger implements INodeType {
|
||||||
const resp = this.getResponseObject();
|
const resp = this.getResponseObject();
|
||||||
const realm = 'Webhook';
|
const realm = 'Webhook';
|
||||||
|
|
||||||
const authentication = this.getNodeParameter('authentication', 0) as string;
|
const incomingAuthentication = this.getNodeParameter('incomingAuthentication', 0) as string;
|
||||||
|
|
||||||
if (authentication === 'basicAuth') {
|
if (incomingAuthentication === 'basicAuth') {
|
||||||
// Basic authorization is needed to call webhook
|
// Basic authorization is needed to call webhook
|
||||||
const httpBasicAuth = this.getCredentials('httpBasicAuth');
|
const httpBasicAuth = this.getCredentials('httpBasicAuth');
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue