From 0f69c30a868e60d3d36da41d6882c511d75ac2b7 Mon Sep 17 00:00:00 2001 From: Mateusz Pietryga Date: Fri, 22 Mar 2024 14:14:19 +0100 Subject: [PATCH] Fix: OAuth2 Authorization Request OPTIONAL parameters are required by bruno (#1797) (#1807) --- packages/bruno-electron/src/ipc/network/oauth2-helper.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/bruno-electron/src/ipc/network/oauth2-helper.js b/packages/bruno-electron/src/ipc/network/oauth2-helper.js index c5a8a6a21..889059821 100644 --- a/packages/bruno-electron/src/ipc/network/oauth2-helper.js +++ b/packages/bruno-electron/src/ipc/network/oauth2-helper.js @@ -49,8 +49,13 @@ const getOAuth2AuthorizationCode = (request, codeChallenge, collectionUid) => { const { callbackUrl, clientId, authorizationUrl, scope, pkce } = oauth2; let oauth2QueryParams = - (authorizationUrl.indexOf('?') > -1 ? '&' : '?') + - `client_id=${clientId}&redirect_uri=${callbackUrl}&response_type=code&scope=${scope}`; + (authorizationUrl.indexOf('?') > -1 ? '&' : '?') + `client_id=${clientId}&response_type=code`; + if (callbackUrl) { + oauth2QueryParams += `&redirect_uri=${callbackUrl}`; + } + if (scope) { + oauth2QueryParams += `&scope=${scope}`; + } if (pkce) { oauth2QueryParams += `&code_challenge=${codeChallenge}&code_challenge_method=S256`; }