JSON Web Tokens (JWT) Generator?

michelhanna
Kilo Guru

What is the best way to generate a JSON Web Token (JWT) in ServiceNow?


There are heaps of implementations in different languages out there (i.e. JSON Web Tokens - jwt.io) and I wrote one myself in Java, but without a MID server I can't run that java code, and I don't want to use MID.


  1. Is there an out of the box way to generate a JWT SHA256withRSA in servicenow giving the p12 file?
  2. Or I could rewrite it in a script include. But I'll have to find an equivalent to some java classes java.security.PrivateKey, KeyStore, Signature,... which I couldn't find.
  3. The only other option that I can think of is to take one of the open source Javascript implementations, refactor it, and put it as a Script include. But it's not going to be easy.

Best also if the solution can be implemented/used in a scoped app.

Thanks,

Michel

12 REPLIES 12

bryanbarnard
ServiceNow Employee
ServiceNow Employee

Hey Michel,



        Currently there is not an out of box way to generate a JWT. You would need to write this functionality in a script include using an open source Javascript implementation. JWT seems to be an authentication type that is growing in popularity and one that is on our list to consider adding support for.



What 3rd party services have you seen that allow authentication using JWT so far? Is there a specific service you are trying to integrate with?



Thanks,


Bryan


Hi Bryan,



Thanks for your reply.



JWT is used to integrate with Salesforce and also with Google Apps, hence my interest.



http://jwt.io/ claims that AWS and Microsoft Azure are also using it but I can't verify this, and I know that for Azure I don't need to build the JWT as explained here.



Anyway, I'm an integration developer, by nature the integration topic attracts me, and I was just trying to learn SN on my own, discovering the platform capabilities. So it's not a real blocker - yet.



Thanks,


Michel


Happy you are thinking about and trying to build integrations with ServiceNow! Thanks for the feedback, we want to hear about integration technologies that customers want to use and any roadblocks they run into. I'm watching adoption of authentication types such as JWT, HMAC, etc... and trying to gauge if/how customers want to use these. Stay tuned to our release notes and hopefully you'll see additional authentication types added.



Until then there may already be a community or share solution where someone has rewritten a OSS Javascript library that could be used in ServiceNow or if you feel motivated to do so please share it!



Thanks,


Bryan


chrisc_
ServiceNow Employee
ServiceNow Employee

Hi Michael,


I've adapted jsrsasign into a Script Include, but I'm still debugging bad signatures that it's generating on NOW with my reference code. Would love to collaborate if you're still tinkering with this.



Right now the Header and Payload are encoded no problem, and the code runs without error, but the resulting JWS signature is not valid.





- Chris