feat(SW-353): dynamic rewards

This commit is contained in:
Christel Westerberg
2024-09-25 15:59:16 +02:00
parent 6a85cfd19c
commit 56cd02f90b
78 changed files with 1568 additions and 4587 deletions

View File

@@ -4,7 +4,9 @@ import { ServiceTokenResponse } from "@/types/tokens"
const SERVICE_TOKEN_REVALIDATE_SECONDS = 3599 // 59 minutes and 59 seconds.
export async function fetchServiceToken(): Promise<ServiceTokenResponse> {
export async function fetchServiceToken(
scopes: string[]
): Promise<ServiceTokenResponse> {
try {
const response = await fetch(`${env.CURITY_ISSUER_USER}/oauth/v2/token`, {
method: "POST",
@@ -16,7 +18,7 @@ export async function fetchServiceToken(): Promise<ServiceTokenResponse> {
grant_type: "client_credentials",
client_id: env.CURITY_CLIENT_ID_SERVICE,
client_secret: env.CURITY_CLIENT_SECRET_SERVICE,
scope: ["hotel"].join(","),
scope: scopes.join(","),
}),
next: {
revalidate: SERVICE_TOKEN_REVALIDATE_SECONDS,