Get upstream token via mapper (JS/Java)

In a mapper (specifially: a Javascript- Mapper), I would like to grab the users upstream access-token (if available - otherwise the actual access- token provided), and authenticate an API with that.
Kindof like this forum post.
So far, I didn’t seem to have found the correct way or method to do so (found this, but whatever ID I give it it will give me back “null” as a value - whether it is “getUsername” or “getToken”.

Can anyone pass me a hint? Java- Examples are welcome, too :slight_smile: