Don't forget to call the onResponse function by adding onResponse(res); at the end of your code, otherwise it won't run. Im my case the code looks like this:
function onResponse(res) {
let data = res.getBody();
bru.setEnvVar("BEARER_TOKEN", data.idToken);
}
onResponse(res);