in salesforce/aa-lwc/force-app/main/default/lwc/agentAssistContainerModule/helpers/integration.js [48:75]
export async function registerAuthToken(consumerKey, consumerSecret, endpoint) {
const access_token = await fetch(
`/services/oauth2/token?` +
new URLSearchParams({
grant_type: "client_credentials",
client_id: consumerKey,
client_secret: consumerSecret
})
)
.then((res) => {
return res.json();
})
.then((data) => {
return data.access_token;
});
return await fetch(endpoint + "/register", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${access_token}`
}
})
.then((res) => {
return res.json();
})
.then((data) => data.token);
}