A payload is a list of tuples (string, string):
let payload =
[
("user", "sam);
("age", "17");
]
Jwt.make Jwt.HS256 "secret" payloadJwt.make returns a signed token (type Jwt.t):
{
header = ...;
payload = [...];
signature = ...;
}Jwt.encode Jwt.HS256 "secret" payload
-->
"eyJhbGciOiJIUzI1NiJ9...."Just decode the token, doesn't verify.
Jwt.decode "eyJhbGciOiJIUzI1NiJ9...."
-->
Ok { header = ...; payload = [...]; signature = ... } Verify and decode. If the verification fails you will get an Error.
Jwt.decode_and_verify "secret" "eyJhbGciOiJIUzI1NiJ9...."
-->
Ok { header = ...; payload = [...]; signature = ... }Jwt.is_valid "secet" "eyJhbGciOiJIUzI1NiJ9...."
-->
true