From a1a0a73e3aba41a4ed067977f0459eed5bb32bcd Mon Sep 17 00:00:00 2001 From: Chuma McPhoy Date: Thu, 25 Jul 2024 11:22:29 +0200 Subject: [PATCH] chore: use correct env var in fetch service token function --- server/tokenManager.ts | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/server/tokenManager.ts b/server/tokenManager.ts index c1027c5ed..e8db5e66d 100644 --- a/server/tokenManager.ts +++ b/server/tokenManager.ts @@ -6,21 +6,25 @@ const SERVICE_TOKEN_REVALIDATE_SECONDS = 3599 // 59 minutes and 59 seconds. async function fetchServiceToken(): Promise { try { - const response = await fetch(`${env.CURITY_ISSUER_USER}/oauth/v2/token`, { - method: "POST", - headers: { - "Content-Type": "application/x-www-form-urlencoded", - Accept: "application/json", - }, - body: new URLSearchParams({ - grant_type: "client_credentials", - client_id: env.CURITY_CLIENT_ID_SERVICE, - client_secret: env.CURITY_CLIENT_SECRET_SERVICE, - }), - next: { - revalidate: SERVICE_TOKEN_REVALIDATE_SECONDS, - }, - }) + const response = await fetch( + `${env.CURITY_ISSUER_SERVICE}/oauth/v2/token`, + { + method: "POST", + headers: { + "Content-Type": "application/x-www-form-urlencoded", + Accept: "application/json", + }, + body: new URLSearchParams({ + grant_type: "client_credentials", + client_id: env.CURITY_CLIENT_ID_SERVICE, + client_secret: env.CURITY_CLIENT_SECRET_SERVICE, + scope: "hotel", + }), + next: { + revalidate: SERVICE_TOKEN_REVALIDATE_SECONDS, + }, + } + ) if (!response.ok) { throw new Error("Failed to obtain service token")