const generateAccessToken = async (clientId, secretKey) => {
const credentials = btoa(`${clientId}:${secretKey}`);
const response = await fetch('https://api.weir.ai/auth/token', {
method: 'POST',
headers: {
'Authorization': `Basic ${credentials}`,
'Content-Type': 'application/json'
}
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
return data.data.accessToken;
};
// Usage
const accessToken = await generateAccessToken('your_client_id', 'your_secret_key');
console.log('Access Token:', accessToken);