feat(Hubspot): Add support for Private App Token Authentication

This commit is contained in:
vcrwr
2022-03-13 11:49:15 +01:00
committed by GitHub
parent 4d4db7f805
commit 2ff13a6842
4 changed files with 40 additions and 0 deletions

View File

@@ -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')) {