Skip to content

Commit

Permalink
fix: convert USE_RELOADLY_SANDBOX to bool
Browse files Browse the repository at this point in the history
  • Loading branch information
rndquu committed Aug 7, 2024
1 parent 276956e commit baab92a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions functions/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface ReloadlyAuthResponse {
}

export async function getAccessToken(env: Env): Promise<AccessToken> {
console.log("Using Reloadly Sandbox:", env.USE_RELOADLY_SANDBOX !== "false");
console.log("Using Reloadly Sandbox:", JSON.parse(env.USE_RELOADLY_SANDBOX));

const url = "https://auth.reloadly.com/oauth/token";
const options = {
Expand All @@ -31,7 +31,7 @@ export async function getAccessToken(env: Env): Promise<AccessToken> {
client_id: env.RELOADLY_API_CLIENT_ID,
client_secret: env.RELOADLY_API_CLIENT_SECRET,
grant_type: "client_credentials",
audience: env.USE_RELOADLY_SANDBOX === "false" ? "https://giftcards.reloadly.com" : "https://giftcards-sandbox.reloadly.com",
audience: JSON.parse(env.USE_RELOADLY_SANDBOX) ? "https://giftcards-sandbox.reloadly.com" : "https://giftcards.reloadly.com",
}),
};

Expand All @@ -40,7 +40,7 @@ export async function getAccessToken(env: Env): Promise<AccessToken> {
const successResponse = (await res.json()) as ReloadlyAuthResponse;
return {
token: successResponse.access_token,
isSandbox: env.USE_RELOADLY_SANDBOX !== "false",
isSandbox: JSON.parse(env.USE_RELOADLY_SANDBOX),
};
}
throw `Getting access token failed: ${JSON.stringify(await res.json())}`;
Expand Down

0 comments on commit baab92a

Please sign in to comment.