refactor(core): continue bounded risk-reduction for token client extraction
This commit is contained in:
+15
-16
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user