Artisan IMG > Json Web Token (JWT) (json-web-token) (8aa56b9d-025f-4a27-911f-499c092afbbd)

JSON Web Token (JWT) Helper
1.0

An implementation of the Json Web Token (JWT) helper standard, offering the ability to sign and verify tokens

Overview
Copy

The main purpose of the JSON Web Token connector is to sign and verify JSON Web Tokens.

It is implemented using the NodeJS jsonwebtoken library. This libraries docs page can be used for more details about the various advanced options.

Operations List
Copy

  • Sign

  • Verify

Authentication
Copy

This connector provides an authentication option that allows you to securely store any key/secret you wish to use to sign/verify the JSON Web Token.

By default the key input property will reference the key stored in the authentication, however you can manually override this with a value if you wish to source your key from elsewhere. Please remember that if you override this key input property, it the value will not be obfuscated in the workflow execution logs.

Example usage
Copy

Using a simple key/secret abcdef and the following JSON payload

1
{
2
"sub": "1234567890",
3
"name": "John Doe",
4
"iat": 1516239022
5
}

You can call the Sign operation and will receive the following JWT response

1
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.IWvkxodTX0kCUbSXguAwSxBlQ-AxTdq2xnweEdfUbgo

If you were to pass this JSON Web Token response into the Verify operation, you should receive the same payload back.

Error Handling
Copy

The Verify operation supports Manual Error Handling to take a different path if the token is valid or invalid. This could be used for example to receive an incoming Webhook payload, verify the payload and respond to the Webhook with different messages depending on the validity of the JWT.