GetJWTByKeyName()

This function allows users to create JSON Web Tokens (JWTs). It uses a key to create a hash of the JWT payload. The hash is included in the JWT content to allow validation. The JWT payload isn’t encrypted.

The difference between GetJWTByKeyName() and its companion function GetJWT() is the first parameter. The first parameter for the GetJWTByKeyName() function is a key name that matches a CustomerKey value.

The GetJWTByKeyName() function has three parameters:

  • keyName (string): Required. A key name matching the CustomerKey value of the MID.
  • algorithm (string): Required. Name of a JWT standard hash algorithm from among HS256, HS384, or HS512.
  • jsonPayload (string): Required. The payload, typically a JSON object with name-value pairs. The payload isn't encrypted.

The GetJWTByKeyName() function only supports pulling a symmetric key from the Marketing Cloud Engagement Public Key Management system based on the customer key value of the key.

Both GetJWTByKeyName() and its companion function GetJWT() convert the key string to a key byte array using UTF-8. It supports Base16, Base64, and ASCII character key strings.

The function returns a JWT string. If syntax for the function is invalid, the parser throws an InvalidFunctionException. If the function call is invalid, for example, as having an invalid parameter value, the parser throws a FunctionExecutionException, including details in an inner exception.

The function outputs a JWT.