0CodeKit icon

0CodeKit

A toolbox of no-code utilities

Actions108

Overview

The node provides a utility to encode JSON Web Tokens (JWTs) within the "Generate" resource and the "Encode JSON Web Token" operation. It takes input data and a secret key, optionally with additional encoding options, and produces a JWT string as output. This is useful in scenarios where you need to create secure tokens for authentication, authorization, or information exchange between parties in web applications or APIs.

Practical examples include:

  • Generating access tokens for user sessions.
  • Creating signed tokens to verify data integrity.
  • Encoding custom claims into a token for API communication.

Properties

Name Meaning
Code Variables A collection of code variables defined in the code editor that can be used dynamically; each variable has a name/ID and value.
Data The raw data (usually a JSON string) that will be encoded into the JWT payload.
Secret The secret key used to sign and verify the JWT token.
Options Optional parameters for the token encoding process, such as algorithm, expiration, issuer, etc., provided as a JSON string.

Output

The node outputs a JSON array where each item contains the result of the JWT encoding operation. The main field in the output JSON is the encoded JWT string representing the signed token.

If binary data were involved, it would be summarized here, but this operation deals only with JSON text data.

Dependencies

  • Requires an API key credential for the external service powering the node's functionality.
  • Relies on an external API endpoint under the path generate/jsonwebtoken/encode to perform the encoding.
  • No direct environment variables are referenced in the static code, but proper API credentials must be configured in n8n.

Troubleshooting

  • Common issues:
    • Invalid or missing secret key causing token signing failure.
    • Malformed JSON data in the "Data" property leading to errors during encoding.
    • Incorrectly formatted options JSON causing parsing or validation errors.
  • Error messages:
    • Errors returned from the external API may indicate invalid parameters or authentication failures.
    • Parsing errors if the "Options" or "Data" fields contain invalid JSON strings.
  • Resolutions:
    • Ensure the secret key is correctly provided and matches expected format.
    • Validate JSON syntax in the "Data" and "Options" fields before execution.
    • Confirm API credentials are set up and valid in n8n.

Links and References

Discussion