fix: update OAuth2 authorization header encoding to remove unnecessary URI encoding (#6263)

This commit is contained in:
Sanjai Kumar
2025-12-02 12:56:08 +05:30
committed by GitHub
parent dd72ee5d77
commit 9d6486ba3e
2 changed files with 6 additions and 6 deletions

View File

@@ -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';

View File

@@ -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') {