From 1e9260c192ff8f1dde29384824421bdaca91341d Mon Sep 17 00:00:00 2001 From: amitjoshi Date: Mon, 11 Nov 2024 17:27:25 +0530 Subject: [PATCH] Refactor and add getCommonHeaders function --- .../powerpages/commands/create-site/Nl2PageService.ts | 6 ++---- .../powerpages/commands/create-site/Nl2SiteService.ts | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/common/chat-participants/powerpages/commands/create-site/Nl2PageService.ts b/src/common/chat-participants/powerpages/commands/create-site/Nl2PageService.ts index 580a5f9d..f410f0fd 100644 --- a/src/common/chat-participants/powerpages/commands/create-site/Nl2PageService.ts +++ b/src/common/chat-participants/powerpages/commands/create-site/Nl2PageService.ts @@ -4,6 +4,7 @@ */ import { ITelemetry } from "../../../../OneDSLoggerTelemetry/telemetry/ITelemetry"; +import { getCommonHeaders } from "../../../../services/AuthenticationProvider"; import { ABOUT_PAGE_TYPE, FAQ_PAGE_TYPE, HOME_PAGE_TYPE, INFO_PAGE_TYPE, NL2PAGE_GENERATE_NEW_PAGE, NL2PAGE_REQUEST_FAILED, NL2PAGE_SCENARIO, NL2PAGE_SCOPE} from "../../PowerPagesChatParticipantConstants"; import { VSCODE_EXTENSION_NL2PAGE_REQUEST_FAILED, VSCODE_EXTENSION_NL2PAGE_REQUEST_SUCCESS } from "../../PowerPagesChatParticipantTelemetryConstants"; @@ -40,10 +41,7 @@ export async function getNL2PageData(aibEndpoint: string, aibToken: string, user const requestInit: RequestInit = { method: "POST", - headers: { - "Content-Type": "application/json", - "Authorization": `Bearer ${aibToken}` - }, + headers: getCommonHeaders(aibToken), body: JSON.stringify(requestBody) }; diff --git a/src/common/chat-participants/powerpages/commands/create-site/Nl2SiteService.ts b/src/common/chat-participants/powerpages/commands/create-site/Nl2SiteService.ts index d7ecd149..20a1a8e8 100644 --- a/src/common/chat-participants/powerpages/commands/create-site/Nl2SiteService.ts +++ b/src/common/chat-participants/powerpages/commands/create-site/Nl2SiteService.ts @@ -6,6 +6,7 @@ import { ITelemetry } from "../../../../OneDSLoggerTelemetry/telemetry/ITelemetry"; import { NL2SITE_GENERATE_NEW_SITE, NL2SITE_INVALID_RESPONSE, NL2SITE_SCENARIO} from "../../PowerPagesChatParticipantConstants"; import { VSCODE_EXTENSION_NL2SITE_REQUEST_SUCCESS, VSCODE_EXTENSION_NL2SITE_REQUEST_FAILED } from "../../PowerPagesChatParticipantTelemetryConstants"; +import { getCommonHeaders } from "../../../../services/AuthenticationProvider"; export async function getNL2SiteData(aibEndpoint: string, aibToken: string, userPrompt: string, sessionId: string, telemetry: ITelemetry) { const requestBody = { @@ -28,10 +29,7 @@ export async function getNL2SiteData(aibEndpoint: string, aibToken: string, user const requestInit: RequestInit = { method: "POST", - headers: { - "Content-Type": "application/json", - "Authorization": `Bearer ${aibToken}` - }, + headers: getCommonHeaders(aibToken), body: JSON.stringify(requestBody) };