From 3bd8f09c88342f92612bf4d0545960645c710b2e Mon Sep 17 00:00:00 2001 From: Mateusz Pietryga Date: Sun, 14 Apr 2024 23:37:14 +0200 Subject: [PATCH] feat: OAuth2 - Supported at the collection level (#1704) --- .../src/components/RequestPane/Auth/index.js | 28 ++++++------------- .../src/ipc/network/prepare-request.js | 3 ++ 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/packages/bruno-app/src/components/RequestPane/Auth/index.js b/packages/bruno-app/src/components/RequestPane/Auth/index.js index 1515e5224..d48856a0c 100644 --- a/packages/bruno-app/src/components/RequestPane/Auth/index.js +++ b/packages/bruno-app/src/components/RequestPane/Auth/index.js @@ -8,8 +8,9 @@ import DigestAuth from './DigestAuth'; import WsseAuth from './WsseAuth'; import ApiKeyAuth from './ApiKeyAuth'; import StyledWrapper from './StyledWrapper'; -import { humanizeRequestAuthMode } from 'utils/collections/index'; +import { humanizeRequestAuthMode } from 'utils/collections'; import OAuth2 from './OAuth2/index'; +import CredentialsPreview from './OAuth2/CredentialsPreview'; const Auth = ({ item, collection }) => { const authMode = item.draft ? get(item, 'draft.request.auth.mode') : get(item, 'request.auth.mode'); @@ -42,24 +43,13 @@ const Auth = ({ item, collection }) => { } case 'inherit': { return ( -
- {collectionAuth?.mode === 'oauth2' ? ( -
-
-
Collection level auth is:
-
{humanizeRequestAuthMode(collectionAuth?.mode)}
-
-
- Note: You need to use scripting to set the access token in the request headers. -
-
- ) : ( - <> -
Auth inherited from the Collection:
-
{humanizeRequestAuthMode(collectionAuth?.mode)}
- - )} -
+ <> +
+
Auth inherited from the Collection:
+
{humanizeRequestAuthMode(collectionAuth?.mode)}
+
+ {collectionAuth?.mode === 'oauth2' && } + ); } } diff --git a/packages/bruno-electron/src/ipc/network/prepare-request.js b/packages/bruno-electron/src/ipc/network/prepare-request.js index 73acf2885..3f0c62f6e 100644 --- a/packages/bruno-electron/src/ipc/network/prepare-request.js +++ b/packages/bruno-electron/src/ipc/network/prepare-request.js @@ -245,6 +245,9 @@ const setAuthHeaders = (axiosRequest, request, collectionRoot) => { axiosRequest.apiKeyAuthValueForQueryParams = apiKeyAuth; } break; + case 'oauth2': + request.auth = collectionAuth; + break; } }