fetch/refresh token - collection/request variables usage fix

This commit is contained in:
lohit-bruno
2025-08-20 16:34:03 +05:30
parent 8dde2701f4
commit ef12401d2e
3 changed files with 8 additions and 6 deletions

View File

@@ -1324,7 +1324,7 @@ export const refreshOauth2Credentials = (payload) => async (dispatch, getState)
request.globalEnvironmentVariables = globalEnvironmentVariables;
return new Promise((resolve, reject) => {
window.ipcRenderer
.invoke('renderer:refresh-oauth2-credentials', { request, collection })
.invoke('renderer:refresh-oauth2-credentials', { itemUid, request, collection })
.then(({ credentials, url, collectionUid, debugInfo, credentialsId }) => {
dispatch(
collectionAddOauth2CredentialsByUrl({

View File

@@ -985,9 +985,7 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
const processEnvVars = getProcessEnvVars(collectionUid);
const partialItem = { uid: itemUid };
const requestTreePath = getTreePathFromCollectionToItem(collection, partialItem);
if (requestTreePath && requestTreePath.length > 0) {
mergeVars(collection, requestCopy, requestTreePath);
}
mergeVars(collection, requestCopy, requestTreePath);
interpolateVars(requestCopy, envVars, runtimeVariables, processEnvVars);
const certsAndProxyConfig = await getCertsAndProxyConfig({
@@ -1108,7 +1106,7 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
}
});
ipcMain.handle('renderer:refresh-oauth2-credentials', async (event, { request, collection }) => {
ipcMain.handle('renderer:refresh-oauth2-credentials', async (event, { itemUid, request, collection }) => {
try {
if (request.oauth2) {
let requestCopy = _.cloneDeep(request);
@@ -1116,7 +1114,11 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
const environment = _.find(environments, (e) => e.uid === activeEnvironmentUid);
const envVars = getEnvVars(environment);
const processEnvVars = getProcessEnvVars(collectionUid);
const partialItem = { uid: itemUid };
const requestTreePath = getTreePathFromCollectionToItem(collection, partialItem);
mergeVars(collection, requestCopy, requestTreePath);
interpolateVars(requestCopy, envVars, runtimeVariables, processEnvVars);
const certsAndProxyConfig = await getCertsAndProxyConfig({
collectionUid,
request: requestCopy,

View File

@@ -47,7 +47,7 @@ const mergeHeaders = (collection, request, requestTreePath) => {
request.headers = Array.from(headers, ([name, value]) => ({ name, value, enabled: true }));
};
const mergeVars = (collection, request, requestTreePath) => {
const mergeVars = (collection, request, requestTreePath = []) => {
let reqVars = new Map();
let collectionRequestVars = get(collection, 'root.request.vars.req', []);
let collectionVariables = {};