in src/libs/zuora.ts [47:75]
async function fetchZuoraBearerToken1(
stage: string,
): Promise<ZuoraBearerToken1> {
// This function returns the entire answer object from zuora
// To retrieve the bearer token itself see fetchZuoraBearerToken2
console.log(`fetching zuora bearer token for stage: ${stage}`);
const url = authTokenQueryUrl(stage);
const client_id = await getSsmValue(stage, 'zuora-client-id');
const client_secret = await getSsmValue(stage, 'zuora-client-secret');
if (!client_id) throw new Error('Zuora client_id not found');
if (!client_secret) throw new Error('Zuora client_secret not found');
const data = {
client_id: client_id,
client_secret: client_secret,
grant_type: 'client_credentials',
};
const response = await fetch(url, {
method: 'POST',
body: new URLSearchParams(data),
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
});
return await response.json();
}