From 25b92169aefc47dc028a11dc008abb4a36d037d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Wed, 21 Jun 2023 12:25:27 +0200 Subject: [PATCH] fix(core): Fix OAuth2 callback for `grantType=clientCredentials` (#6500) Co-authored-by: agobrech --- .../src/credentials/oauth2Credential.api.ts | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/packages/cli/src/credentials/oauth2Credential.api.ts b/packages/cli/src/credentials/oauth2Credential.api.ts index 2e31432f0b..03ac4f0c50 100644 --- a/packages/cli/src/credentials/oauth2Credential.api.ts +++ b/packages/cli/src/credentials/oauth2Credential.api.ts @@ -272,24 +272,19 @@ oauth2CredentialController.get( scopes: split(get(oauthCredentials, 'scope', 'openid,') as string, ','), }; - if ((get(oauthCredentials, 'authentication', 'header') as string) === 'body') { + if (oauthCredentials.grantType === 'pkce') { + options = { + body: { code_verifier: decryptedDataOriginal.codeVerifier }, + }; + } else if ((get(oauthCredentials, 'authentication', 'header') as string) === 'body') { options = { body: { - ...(oauthCredentials.grantType === 'pkce' && { - code_verifier: decryptedDataOriginal.codeVerifier, - }), - ...(oauthCredentials.grantType === 'authorizationCode' && { - client_id: get(oauthCredentials, 'clientId') as string, - client_secret: get(oauthCredentials, 'clientSecret', '') as string, - }), + client_id: get(oauthCredentials, 'clientId') as string, + client_secret: get(oauthCredentials, 'clientSecret', '') as string, }, }; // @ts-ignore delete oAuth2Parameters.clientSecret; - } else if (oauthCredentials.grantType === 'pkce') { - options = { - body: { code_verifier: decryptedDataOriginal.codeVerifier }, - }; } await Container.get(ExternalHooks).run('oauth2.callback', [oAuth2Parameters]);