RVS JWT icon

RVS JWT

Simple tool to generate and verify JWT Tokens

Overview

This node provides functionality to generate and verify JSON Web Tokens (JWTs). It is useful in scenarios where secure token-based authentication or data exchange is required. For example, you can use it to create a signed JWT for user authentication or to verify the authenticity and integrity of an incoming JWT token.

  • Generate JWT: Takes a payload (JSON object or string) and signs it with a private key to produce a JWT.
  • Verify JWT: Takes a JWT token and verifies it using a private key, returning the decoded token data or an error indication.

Practical examples:

  • Generating a JWT to authenticate API requests.
  • Verifying a JWT received from a client to ensure it is valid and untampered.

Properties

Name Meaning
Operation Choose between "Generate JWT" or "Verify JWT" operations.
Payload JSON data object or string to be signed (for generation) or JWT token string to verify.
Target Object Name The key name under which the result (generated token or verification result) will be stored.
Private Key Private key string used for signing or verifying the JWT.
Options (Verify JWT only) Collection of modifiers:
- Raise Exception: Whether to throw an error on verification failure or return an error object.
- Extend Input Object: Whether to add the verification result into the existing input JSON object or output as standalone.

Output

The node outputs JSON data containing the result under the specified target object name:

  • For Generate JWT: The output JSON contains the generated JWT token string.
  • For Verify JWT: The output JSON contains the decoded JWT payload along with an error field set to false if verification succeeded. If verification fails and exceptions are not raised, the output contains { error: true }.

If the "Extend Input Object" option is enabled during verification, the node merges the verification result into each input item's JSON data under the target object key; otherwise, it outputs the result as a new JSON object.

The node does not output binary data.

Dependencies

  • Uses the external library jsonwebtoken for JWT signing and verification.
  • Requires a private key string for cryptographic operations.
  • No additional external services or environment variables are needed beyond providing the private key.

Troubleshooting

  • Error: "Payload must be defined in type string or object"
    Occurs if the payload parameter is empty or invalid when generating a JWT. Ensure the payload is provided as a valid JSON object or string.

  • Verification errors
    If the JWT token is invalid, expired, or the private key does not match, verification will fail. Depending on the "Raise Exception" option, the node either throws an error or returns an object with error: true.
    To handle errors gracefully, consider enabling "Raise Exception" to catch issues explicitly or disable it to process error objects downstream.

  • Invalid private key
    Using an incorrect or malformed private key will cause signing or verification to fail. Verify that the private key matches the expected format and algorithm.

Links and References

Discussion