I second @fvodden on this. Encapsulating your setup in a function makes it clean an reusable.
That said, here’s my first attempt at a SalesForce API call (before you wonder if I’m nuts all the client secrets etc are obfuscated)
We actually went live using this but in Func delegates as we unfortunately didn’t have Efx functions yet. Working on redoing them in efx Functions this summer.