feat(core): Add Support for Additional Body Properties in OAuth2 API Client Credentials Flow (#16573)

Co-authored-by: Elias Meire <elias@meire.dev>
This commit is contained in:
David Ma
2025-08-05 06:26:04 -04:00
committed by GitHub
parent bdc3a9172d
commit 22ca768c13
2 changed files with 45 additions and 8 deletions

View File

@@ -929,6 +929,22 @@ export function applyPaginationRequestData(
return merge({}, requestData, preparedPaginationData);
}
function createOAuth2Client(credentials: OAuth2CredentialData): ClientOAuth2 {
return new ClientOAuth2({
clientId: credentials.clientId,
clientSecret: credentials.clientSecret,
accessTokenUri: credentials.accessTokenUrl,
scopes: (credentials.scope as string).split(' '),
ignoreSSLIssues: credentials.ignoreSSLIssues,
authentication: credentials.authentication ?? 'header',
...(credentials.additionalBodyProperties && {
additionalBodyProperties: jsonParse(credentials.additionalBodyProperties, {
fallbackValue: {},
}),
}),
});
}
/** @deprecated make these requests using httpRequestWithAuthentication */
export async function requestOAuth2(
this: IAllExecuteFunctions,
@@ -950,14 +966,7 @@ export async function requestOAuth2(
throw new ApplicationError('OAuth credentials not connected');
}
const oAuthClient = new ClientOAuth2({
clientId: credentials.clientId,
clientSecret: credentials.clientSecret,
accessTokenUri: credentials.accessTokenUrl,
scopes: (credentials.scope as string).split(' '),
ignoreSSLIssues: credentials.ignoreSSLIssues,
authentication: credentials.authentication ?? 'header',
});
const oAuthClient = createOAuth2Client(credentials);
let oauthTokenData = credentials.oauthTokenData as ClientOAuth2TokenData;
// if it's the first time using the credentials, get the access token and save it into the DB.