feat(LinkedIn Node): Add support for Community Management API (#7451)

This commit is contained in:
Jon
2024-01-24 09:28:42 +00:00
committed by GitHub
parent 7386f79362
commit 7660d7e735
5 changed files with 122 additions and 9 deletions

View File

@@ -25,6 +25,14 @@ export async function linkedInApiRequest(
binary?: boolean,
_headers?: object,
): Promise<any> {
const authenticationMethod = this.getNodeParameter('authentication', 0);
const credentialType =
authenticationMethod === 'standard'
? 'linkedInOAuth2Api'
: 'linkedInCommunityManagementOAuth2Api';
const baseUrl = 'https://api.linkedin.com';
let options: OptionsWithUrl = {
headers: {
Accept: 'application/json',
@@ -33,9 +41,10 @@ export async function linkedInApiRequest(
},
method,
body,
url: binary ? endpoint : `https://api.linkedin.com/rest${endpoint}`,
url: binary ? endpoint : `${baseUrl}${endpoint.includes('v2') ? '' : '/rest'}${endpoint}`,
json: true,
};
options = Object.assign({}, options, {
resolveWithFullResponse: true,
});
@@ -51,7 +60,7 @@ export async function linkedInApiRequest(
try {
return resolveHeaderData(
await this.helpers.requestOAuth2.call(this, 'linkedInOAuth2Api', options, {
await this.helpers.requestOAuth2.call(this, credentialType, options, {
tokenType: 'Bearer',
}),
);