I am working on generating JWT (Jason Web Tokens) for use with the API (Application Programming Interface) for Box. Box is a company that does “File sharing, storage and collaboration”. I have created a small group of functions to work through automating the handling the accounts of employees that have left the company.
In an effort to create a process that is entirely hands free, I need to be able to authenticate with Box’s interface securely without being prompted. I may get into what a JST is an how it works after I get this all pulled together, but for right now, there are three pieces of data used in a JWT, the Header, Claims, and Signature, and they need to be serialized to UTF-8 bytes, then encoded using the Base64url encoding.
One of the components of the Claims piece is the ‘jti’, which is a random hex string.
One of the Box employees has written an example of how to do this in another language, with I am hoping will help someone to identify and show me how to do this in PowerShell.
var sessionToken = crypto.randomBytes(20).toString('hex');