Skip to content

Commit f0fd692

Browse files
committed
Fix #1683 allow OAuth2 authorizationUrl with user provided query parameters
1 parent e2d1f52 commit f0fd692

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/bruno-electron/src/ipc/network/oauth2-helper.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,13 @@ const getOAuth2AuthorizationCode = (request, codeChallenge) => {
4747
const { oauth2 } = request;
4848
const { callbackUrl, clientId, authorizationUrl, scope, pkce } = oauth2;
4949

50-
let authorizationUrlWithQueryParams = `${authorizationUrl}?client_id=${clientId}&redirect_uri=${callbackUrl}&response_type=code&scope=${scope}`;
50+
let oauth2QueryParams =
51+
(authorizationUrl.indexOf('?') > -1 ? '&' : '?') +
52+
`client_id=${clientId}&redirect_uri=${callbackUrl}&response_type=code&scope=${scope}`;
5153
if (pkce) {
52-
authorizationUrlWithQueryParams += `&code_challenge=${codeChallenge}&code_challenge_method=S256`;
54+
oauth2QueryParams += `&code_challenge=${codeChallenge}&code_challenge_method=S256`;
5355
}
56+
const authorizationUrlWithQueryParams = authorizationUrl + oauth2QueryParams;
5457
try {
5558
const { authorizationCode } = await authorizeUserInWindow({
5659
authorizeUrl: authorizationUrlWithQueryParams,

0 commit comments

Comments
 (0)