Pike v8.1 release 6

Method Web.encode_jwt()


Method encode_jwt

string(7bit) encode_jwt(Crypto.Sign.State|Crypto.MAC.State sign, mapping(string:string|int) claims)

Description

Encode a JSON Web Token (JWT).

Parameter sign

The asymetric private or MAC key to use for signing the result.

Parameter claims

The set of claims for the token. See RFC 7519 section 4.

Returns

Returns 0 (zero) on encoding failure (usually that sign doesn't support JWS.

Returns a corresponding JWT on success.

Note

The claim "iat" (RFC 7519 section 4.1.6 is added unconditionally, and the claim "jti" (RFC 7519 section 4.1.7) is added if not already present.

See also

decode_jwt(), RFC 7519 section 4