mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 12:57:29 -08:00
⚡ Add OAuth to HubSpot Trigger node credentials (#2166)
* 🔨 HubSpot Trigger node credentials * ⚡ Small changes * ⚡ Add breaking change message Co-authored-by: ricardo <ricardoespinoza105@gmail.com>
This commit is contained in:
parent
469ac1d912
commit
5ea4dc03b8
|
@ -2,6 +2,20 @@
|
||||||
|
|
||||||
This list shows all the versions which include breaking changes and how to upgrade.
|
This list shows all the versions which include breaking changes and how to upgrade.
|
||||||
|
|
||||||
|
## 0.139.0
|
||||||
|
|
||||||
|
### What changed?
|
||||||
|
|
||||||
|
For the HubSpot Trigger node, the authentication process has changed to OAuth2.
|
||||||
|
|
||||||
|
### When is action necessary?
|
||||||
|
|
||||||
|
If you are using the Hubspot Trigger.
|
||||||
|
|
||||||
|
### How to upgrade:
|
||||||
|
|
||||||
|
Create an app in HubSpot, use the Client ID, Client Secret, App ID, and the Developer Key, and complete the OAuth2 flow.
|
||||||
|
|
||||||
## 0.135.0
|
## 0.135.0
|
||||||
|
|
||||||
### What changed?
|
### What changed?
|
||||||
|
|
|
@ -3,11 +3,45 @@ import {
|
||||||
INodeProperties,
|
INodeProperties,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
|
const scopes = [
|
||||||
|
'contacts',
|
||||||
|
];
|
||||||
|
|
||||||
export class HubspotDeveloperApi implements ICredentialType {
|
export class HubspotDeveloperApi implements ICredentialType {
|
||||||
name = 'hubspotDeveloperApi';
|
name = 'hubspotDeveloperApi';
|
||||||
displayName = 'Hubspot Developer API';
|
displayName = 'Hubspot Developer API';
|
||||||
documentationUrl = 'hubspot';
|
documentationUrl = 'hubspot';
|
||||||
|
extends = [
|
||||||
|
'oAuth2Api',
|
||||||
|
];
|
||||||
properties: INodeProperties[] = [
|
properties: INodeProperties[] = [
|
||||||
|
{
|
||||||
|
displayName: 'Authorization URL',
|
||||||
|
name: 'authUrl',
|
||||||
|
type: 'hidden',
|
||||||
|
default: 'https://app.hubspot.com/oauth/authorize',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Access Token URL',
|
||||||
|
name: 'accessTokenUrl',
|
||||||
|
type: 'hidden',
|
||||||
|
default: 'https://api.hubapi.com/oauth/v1/token',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Auth URI Query Parameters',
|
||||||
|
name: 'authQueryParameters',
|
||||||
|
type: 'hidden',
|
||||||
|
default: 'grant_type=authorization_code',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Authentication',
|
||||||
|
name: 'authentication',
|
||||||
|
type: 'hidden',
|
||||||
|
default: 'body',
|
||||||
|
description: 'Resource to consume.',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Developer API Key',
|
displayName: 'Developer API Key',
|
||||||
name: 'apiKey',
|
name: 'apiKey',
|
||||||
|
@ -15,18 +49,18 @@ export class HubspotDeveloperApi implements ICredentialType {
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Client Secret',
|
displayName: 'APP ID',
|
||||||
name: 'clientSecret',
|
|
||||||
type: 'string',
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
displayName: 'App ID',
|
|
||||||
name: 'appId',
|
name: 'appId',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
required: true,
|
required: true,
|
||||||
default: '',
|
default: '',
|
||||||
description: 'The App ID',
|
description: 'The APP ID',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Scope',
|
||||||
|
name: 'scope',
|
||||||
|
type: 'hidden',
|
||||||
|
default: scopes.join(' '),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -370,16 +370,12 @@ export class HubspotTrigger implements INodeType {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// check signare if client secret is defined
|
|
||||||
|
|
||||||
if (credentials.clientSecret !== '') {
|
|
||||||
const hash = `${credentials!.clientSecret}${JSON.stringify(bodyData)}`;
|
const hash = `${credentials!.clientSecret}${JSON.stringify(bodyData)}`;
|
||||||
const signature = createHash('sha256').update(hash).digest('hex');
|
const signature = createHash('sha256').update(hash).digest('hex');
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
if (signature !== headerData['x-hubspot-signature']) {
|
if (signature !== headerData['x-hubspot-signature']) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = 0; i < bodyData.length; i++) {
|
for (let i = 0; i < bodyData.length; i++) {
|
||||||
const subscriptionType = bodyData[i].subscriptionType as string;
|
const subscriptionType = bodyData[i].subscriptionType as string;
|
||||||
|
|
Loading…
Reference in a new issue