vasupabbaraju_53143
11/05/2025, 5:05 PMAnswer Overflow
11/05/2025, 5:05 PMyindev_67585
11/05/2025, 6:08 PMvasupabbaraju_53143
11/05/2025, 6:23 PMvasupabbaraju_53143
11/05/2025, 6:30 PMvasupabbaraju_53143
11/05/2025, 6:37 PMnicolastse
11/05/2025, 7:01 PMyindev_67585
11/05/2025, 7:38 PMvasupabbaraju_53143
11/05/2025, 8:18 PMyindev_67585
11/06/2025, 2:52 AMexport const getTokenDirectly = async (tokenConfig: any) => {
const { tsHost, username, password, secretKey } = tokenConfig;
const apiUrl = `${tsHost}/api/rest/2.0/auth/token/full`;
const requestBody: any = {
username: username,
validity_time_in_sec: 30000,
};
if (password && password !== '') {
requestBody.password = password;
} else if (secretKey && secretKey !== '') {
requestBody.secret_key = secretKey;
} else {
throw new Error('Either password or secret_key must be provided');
}
try {
const response = await fetch(apiUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
body: JSON.stringify(requestBody),
});
const data = await response.json();
if (!response.ok) {
throw new Error(data.error?.message || `API Error: ${response.status}`);
}
return data.token;
} catch (error: any) {
throw error;
}
};nicolastse
11/10/2025, 5:55 PMvasupabbaraju_53143
11/28/2025, 5:47 PMvasupabbaraju_53143
12/01/2025, 2:17 PMyindev_67585
12/02/2025, 5:55 AMshikharts_67242
12/02/2025, 6:34 AM