refactor(core): continue bounded risk-reduction for token client extraction

This commit is contained in:
2026-03-25 10:24:42 +00:00
parent a715e5fac7
commit 342c7ed457
2 changed files with 51 additions and 16 deletions
+15 -16
View File
@@ -1,4 +1,4 @@
import axios from "axios";
import { requestJson } from "../clients/endpointClient";
import { ACCESS_TOKEN_ENDPOINT, TENANT_ID } from "./env";
import { consoleLogger } from "./logger";
@@ -23,20 +23,19 @@ const tokenConfig = {
}
};
export const getToken = () => {
return axios
.post(
`${ACCESS_TOKEN_ENDPOINT}${TENANT_ID}/oauth2/v2.0/token`,
tokenBody,
tokenConfig
)
.then((res) => res.data)
.then((data) => {
cache.tokenResponse = data;
return data;
})
.catch((error) => {
consoleLogger(error);
return error;
export const getToken = async () => {
try {
const data = await requestJson({
method: "post",
url: `${ACCESS_TOKEN_ENDPOINT}${TENANT_ID}/oauth2/v2.0/token`,
data: tokenBody,
...tokenConfig
});
cache.tokenResponse = data;
return data;
} catch (error) {
consoleLogger(error);
return error;
}
};