jwtuniqueidentifiermirthepic

How to generate jti ( JWT Id) in java script?


To fetch EPIC data through mirth I want to create JWT so I followed documentation https://fhir.epic.com/Documentation?docId=oauth2&section=BackendOAuth2Guide.

I dont know to how to generate jti which is required field in payload. There are no specific rules or steps available online to follow and generate jti. Please guide me.

I tried the accepted answers as viewers suggested I tried generating jti using the accepted answers here.

Got this r9d2ex8zs for following code

return Math.random().toString(36).split('').filter( function(value, index, self) { 
    return self.indexOf(value) === index;
}).join('').substr(2,50);

Got this h75tvne5n00000000000000000 for following syntax

return ((Math.random().toString(36)+'00000000000000000').slice(2, 50)).slice(2, 50);

Solution

  • You can generate a random string. No need for any dependencies or external API. The function in the accepted answer is fine for this use case.