From ff31b961b7067d099dd6abfd79e2f2ffa5585b13 Mon Sep 17 00:00:00 2001 From: pemontto <939704+pemontto@users.noreply.github.com> Date: Mon, 29 Aug 2022 06:53:57 -0400 Subject: [PATCH] Use instance URL for OAuth callback (#3560) Use editor URL instead of webhook url for oauth connections --- packages/cli/src/api/oauth2Credential.api.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/api/oauth2Credential.api.ts b/packages/cli/src/api/oauth2Credential.api.ts index 5769e714dc..e6def39033 100644 --- a/packages/cli/src/api/oauth2Credential.api.ts +++ b/packages/cli/src/api/oauth2Credential.api.ts @@ -18,7 +18,7 @@ import { import { resolve as pathResolve } from 'path'; import querystring from 'querystring'; -import { Db, ICredentialsDb, ResponseHelper, WebhookHelpers } from '..'; +import { Db, ICredentialsDb, ResponseHelper } from '..'; import { RESPONSE_ERROR_MESSAGES } from '../constants'; import { CredentialsHelper, @@ -29,6 +29,7 @@ import { getLogger } from '../Logger'; import { OAuthRequest } from '../requests'; import { externalHooks } from '../Server'; import config from '../../config'; +import { getInstanceBaseUrl } from '../UserManagement/UserManagementHelper'; export const oauth2CredentialController = express.Router(); @@ -109,7 +110,7 @@ oauth2CredentialController.get( clientSecret: get(oauthCredentials, 'clientSecret', '') as string, accessTokenUri: get(oauthCredentials, 'accessTokenUrl', '') as string, authorizationUri: get(oauthCredentials, 'authUrl', '') as string, - redirectUri: `${WebhookHelpers.getWebhookBaseUrl()}${restEndpoint}/oauth2-credential/callback`, + redirectUri: `${getInstanceBaseUrl()}${restEndpoint}/oauth2-credential/callback`, scopes: split(get(oauthCredentials, 'scope', 'openid,') as string, ','), state: stateEncodedStr, }; @@ -265,7 +266,7 @@ oauth2CredentialController.get( clientSecret: get(oauthCredentials, 'clientSecret', '') as string | undefined, accessTokenUri: get(oauthCredentials, 'accessTokenUrl', '') as string, authorizationUri: get(oauthCredentials, 'authUrl', '') as string, - redirectUri: `${WebhookHelpers.getWebhookBaseUrl()}${restEndpoint}/oauth2-credential/callback`, + redirectUri: `${getInstanceBaseUrl()}${restEndpoint}/oauth2-credential/callback`, scopes: split(get(oauthCredentials, 'scope', 'openid,') as string, ','), };