From 9d6486ba3ed69768a01a48485c83ed15d667cb22 Mon Sep 17 00:00:00 2001 From: Sanjai Kumar <161328623+sanjaikumar-bruno@users.noreply.github.com> Date: Tue, 2 Dec 2025 12:56:08 +0530 Subject: [PATCH] fix: update OAuth2 authorization header encoding to remove unnecessary URI encoding (#6263) --- packages/bruno-electron/src/utils/oauth2.js | 8 ++++---- packages/bruno-requests/src/auth/oauth2-helper.ts | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/bruno-electron/src/utils/oauth2.js b/packages/bruno-electron/src/utils/oauth2.js index 4c24c7f22..cf33efc15 100644 --- a/packages/bruno-electron/src/utils/oauth2.js +++ b/packages/bruno-electron/src/utils/oauth2.js @@ -252,7 +252,7 @@ const getOAuth2TokenUsingAuthorizationCode = async ({ request, collectionUid, fo 'Accept': 'application/json', }; if (credentialsPlacement === "basic_auth_header") { - axiosRequestConfig.headers['Authorization'] = `Basic ${Buffer.from(`${encodeURIComponent(clientId)}:${encodeURIComponent(clientSecret)}`).toString('base64')}`; + axiosRequestConfig.headers['Authorization'] = `Basic ${Buffer.from(`${clientId}:${clientSecret}`).toString('base64')}`; } const data = { grant_type: 'authorization_code', @@ -451,7 +451,7 @@ const getOAuth2TokenUsingClientCredentials = async ({ request, collectionUid, fo 'Accept': 'application/json', }; if (credentialsPlacement === "basic_auth_header" && clientSecret && clientSecret.trim() !== '') { - axiosRequestConfig.headers['Authorization'] = `Basic ${Buffer.from(`${encodeURIComponent(clientId)}:${encodeURIComponent(clientSecret)}`).toString('base64')}`; + axiosRequestConfig.headers['Authorization'] = `Basic ${Buffer.from(`${clientId}:${clientSecret}`).toString('base64')}`; } const data = { grant_type: 'client_credentials', @@ -598,7 +598,7 @@ const getOAuth2TokenUsingPasswordCredentials = async ({ request, collectionUid, 'Accept': 'application/json', }; if (credentialsPlacement === "basic_auth_header" && clientSecret && clientSecret.trim() !== '') { - axiosRequestConfig.headers['Authorization'] = `Basic ${Buffer.from(`${encodeURIComponent(clientId)}:${encodeURIComponent(clientSecret)}`).toString('base64')}`; + axiosRequestConfig.headers['Authorization'] = `Basic ${Buffer.from(`${clientId}:${clientSecret}`).toString('base64')}`; } const data = { grant_type: 'password', @@ -659,7 +659,7 @@ const refreshOauth2Token = async ({ requestCopy, collectionUid, certsAndProxyCon 'Accept': 'application/json' }; if (credentialsPlacement === "basic_auth_header") { - axiosRequestConfig.headers['Authorization'] = `Basic ${Buffer.from(`${encodeURIComponent(clientId)}:${encodeURIComponent(clientSecret)}`).toString('base64')}`; + axiosRequestConfig.headers['Authorization'] = `Basic ${Buffer.from(`${clientId}:${clientSecret}`).toString('base64')}`; } axiosRequestConfig.url = url; axiosRequestConfig.responseType = 'arraybuffer'; diff --git a/packages/bruno-requests/src/auth/oauth2-helper.ts b/packages/bruno-requests/src/auth/oauth2-helper.ts index a8f499886..09ab59e79 100644 --- a/packages/bruno-requests/src/auth/oauth2-helper.ts +++ b/packages/bruno-requests/src/auth/oauth2-helper.ts @@ -145,7 +145,7 @@ const fetchTokenClientCredentials = async (oauth2Config: OAuth2Config) => { } if (credentialsPlacement === 'basic_auth_header') { - requestConfig.headers['Authorization'] = `Basic ${Buffer.from(`${encodeURIComponent(clientId)}:${encodeURIComponent(clientSecret!)}`).toString('base64')}`; + requestConfig.headers['Authorization'] = `Basic ${Buffer.from(`${clientId}:${clientSecret!}`).toString('base64')}`; } if (credentialsPlacement !== 'basic_auth_header') { @@ -246,7 +246,7 @@ const fetchTokenPassword = async (oauth2Config: OAuth2Config) => { } if (credentialsPlacement === 'basic_auth_header') { - requestConfig.headers['Authorization'] = `Basic ${Buffer.from(`${encodeURIComponent(clientId)}:${encodeURIComponent(clientSecret!)}`).toString('base64')}`; + requestConfig.headers['Authorization'] = `Basic ${Buffer.from(`${clientId}:${clientSecret!}`).toString('base64')}`; } if (credentialsPlacement !== 'basic_auth_header') {