JWT.SIGN

JWT.SIGN signs the body of a JSON Web Token (JWT) using a specified algorithm and signature. It attempts to encode its payload as JSON.

Xapix currently supports the HS256, HS384, HS512 algorithms.

Syntax

JWT.SIGN(arg1, arg2, arg3, [args...])

Arguments

Definition

arg1

A string denoting the algorithm to be used.

arg2

The payload as an object for which to generate a signature.

arg3

Signature to use in signing the JWT.

[args...]

An additional set of arguments for use with certain subsets of algorithms.

Examples

Example 1: Create a signed JWT

To create a JWT, we would use JWT.SIGN that includes an algorithm and signature:

JWT.SIGN('HS256', OBJECT.NEW({{\"foo\", 1}, {\"bar\", {4, 5, 'qwe'}}}), 'password')

The above snippet would use the provided algorithm and signature to create a JWT as shown below.

eyJhbGciOiJIUzI1NiJ9.
eyJuaWwiOls0LDUsInF3ZSJdfQ.
slTZMJTvamnCLdyAk4x_HrIkK_SESjboxdHiuFj-meM