Skip to content

Commit

Permalink
fix: change sandbox env var to string
Browse files Browse the repository at this point in the history
  • Loading branch information
EresDev committed Jul 17, 2024
1 parent f6b7278 commit 743aac2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions functions/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const commonHeaders = {
};

export interface Env {
USE_RELOADLY_SANDBOX: boolean;
USE_RELOADLY_SANDBOX: string;
RELOADLY_API_CLIENT_ID: string;
RELOADLY_API_CLIENT_SECRET: string;
}
Expand All @@ -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:", env.USE_RELOADLY_SANDBOX !== "false");

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: env.USE_RELOADLY_SANDBOX === "false" ? "https://giftcards.reloadly.com" : "https://giftcards-sandbox.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: env.USE_RELOADLY_SANDBOX !== "false",
};
}
throw `Getting access token failed: ${JSON.stringify(await res.json())}`;
Expand Down

0 comments on commit 743aac2

Please sign in to comment.