create
Ce contenu n’est pas encore disponible dans votre langue.
Build and sign a new JWT with custom claims, an expiration, and a choice of algorithm. Outputs the signed token string to stdout.
jwtop create --alg <alg> (--secret <secret> | --key <pem-file>) [options]| Flag | Description |
|---|---|
--alg | Signing algorithm, e.g. HS256, RS256, ES256 (required) |
--secret | HMAC secret string |
--key | Path or URL to a PEM-encoded private key file |
--claim key=value | Custom claim (repeatable) |
--sub | Subject claim (sub) |
--iss | Issuer claim (iss) |
--aud | Audience claim (aud) |
--exp | Expiration duration, e.g. 1h, 30m, 24h |
--iat | Include issued-at (iat) claim set to the current time |
Claim value parsing
Section titled “Claim value parsing”Claim values passed via --claim or --sub/--iss/--aud are auto-parsed:
- Parsed as
int64if the value is a valid integer. - Parsed as
boolif the value istrueorfalse. - Stored as a string otherwise.
Examples
Section titled “Examples”HS256 with standard claims
jwtop create --alg HS256 --secret mysecret \ --sub user123 --iss myapp --exp 1h --iatHS256 with custom claims
jwtop create --alg HS256 --secret mysecret \ --sub user123 --claim role=admin --claim plan=proRS256 with a private key
jwtop create --alg RS256 --key /path/to/private.pem \ --sub user123 --exp 24h