const client_id = process.env.STRANGELOOP_CLIENT_ID;
const client_secret = process.env.STRANGELOOP_CLIENT_SECRET;
const options = {
method: "POST",
url: "https://customer-console-prod.auth.us-west-2.amazoncognito.com/oauth2/token",
headers: { "content-type": "application/x-www-form-urlencoded" },
data: `grant_type=client_credentials&client_id=${client_id}&client_secret=${client_secret}&scope=https://api.strangelooplabs.ai/default`,
};
const response = await axios(options);
const tokenData = {
token: response.data.access_token,
expiry: Date.now() + response.data.expires_in * 1000,
};
fs.writeFileSync("token.json", JSON.stringify(tokenData));
return tokenData.token;
};