mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -08:00
feat(Hubspot): Add support for Private App Token Authentication
This commit is contained in:
parent
4d4db7f805
commit
2ff13a6842
|
@ -0,0 +1,18 @@
|
|||
import {
|
||||
ICredentialType,
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export class HubspotAppToken implements ICredentialType {
|
||||
name = 'hubspotAppToken';
|
||||
displayName = 'Hubspot App Token';
|
||||
documentationUrl = 'hubspot';
|
||||
properties: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'App Token',
|
||||
name: 'appToken',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
];
|
||||
}
|
|
@ -27,6 +27,7 @@ export async function hubspotApiRequest(this: IHookFunctions | IExecuteFunctions
|
|||
const options: OptionsWithUri = {
|
||||
method,
|
||||
qs: query,
|
||||
headers: {},
|
||||
uri: uri || `https://api.hubapi.com${endpoint}`,
|
||||
body,
|
||||
json: true,
|
||||
|
@ -39,6 +40,11 @@ export async function hubspotApiRequest(this: IHookFunctions | IExecuteFunctions
|
|||
|
||||
options.qs.hapikey = credentials!.apiKey as string;
|
||||
return await this.helpers.request!(options);
|
||||
} else if (authenticationMethod === 'appToken') {
|
||||
const credentials = await this.getCredentials('hubspotAppToken');
|
||||
|
||||
options.headers!['Authorization'] = `Bearer ${credentials!.appToken}`;
|
||||
return await this.helpers.request!(options);
|
||||
} else if (authenticationMethod === 'developerApi') {
|
||||
if (endpoint.includes('webhooks')) {
|
||||
|
||||
|
|
|
@ -97,6 +97,17 @@ export class Hubspot implements INodeType {
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'hubspotAppToken',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'appToken',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'hubspotOAuth2Api',
|
||||
required: true,
|
||||
|
@ -119,6 +130,10 @@ export class Hubspot implements INodeType {
|
|||
name: 'API Key',
|
||||
value: 'apiKey',
|
||||
},
|
||||
{
|
||||
name: 'App Token',
|
||||
value: 'appToken',
|
||||
},
|
||||
{
|
||||
name: 'OAuth2',
|
||||
value: 'oAuth2',
|
||||
|
|
|
@ -143,6 +143,7 @@
|
|||
"dist/credentials/HttpHeaderAuth.credentials.js",
|
||||
"dist/credentials/HttpQueryAuth.credentials.js",
|
||||
"dist/credentials/HubspotApi.credentials.js",
|
||||
"dist/credentials/HubspotAppToken.credentials.js",
|
||||
"dist/credentials/HubspotDeveloperApi.credentials.js",
|
||||
"dist/credentials/HubspotOAuth2Api.credentials.js",
|
||||
"dist/credentials/HumanticAiApi.credentials.js",
|
||||
|
|
Loading…
Reference in a new issue