chore: use correct env var in fetch service token function

This commit is contained in:
Chuma McPhoy
2024-07-25 11:22:29 +02:00
parent 1885f8080a
commit a1a0a73e3a

View File

@@ -6,7 +6,9 @@ const SERVICE_TOKEN_REVALIDATE_SECONDS = 3599 // 59 minutes and 59 seconds.
async function fetchServiceToken(): Promise<ServiceTokenResponse> { async function fetchServiceToken(): Promise<ServiceTokenResponse> {
try { try {
const response = await fetch(`${env.CURITY_ISSUER_USER}/oauth/v2/token`, { const response = await fetch(
`${env.CURITY_ISSUER_SERVICE}/oauth/v2/token`,
{
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/x-www-form-urlencoded", "Content-Type": "application/x-www-form-urlencoded",
@@ -16,11 +18,13 @@ async function fetchServiceToken(): Promise<ServiceTokenResponse> {
grant_type: "client_credentials", grant_type: "client_credentials",
client_id: env.CURITY_CLIENT_ID_SERVICE, client_id: env.CURITY_CLIENT_ID_SERVICE,
client_secret: env.CURITY_CLIENT_SECRET_SERVICE, client_secret: env.CURITY_CLIENT_SECRET_SERVICE,
scope: "hotel",
}), }),
next: { next: {
revalidate: SERVICE_TOKEN_REVALIDATE_SECONDS, revalidate: SERVICE_TOKEN_REVALIDATE_SECONDS,
}, },
}) }
)
if (!response.ok) { if (!response.ok) {
throw new Error("Failed to obtain service token") throw new Error("Failed to obtain service token")