mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user