Skip to main content
Version: 4.x

WP-CLI Commands for WordPress JWT

Simple JWT Login registers a wp jwt command namespace in WP-CLI. It covers the plugin's main operations: initial setup, issuing and revoking JWTs, signing key rotation, API keys, auth codes, settings, diagnostics, audit logs, and webhooks. The commands run in the WordPress process on the server, so they do not need HTTP access to the site.

wp jwt --help
wp jwt config --help
Since version 4.3.0

The commands are part of the plugin. The separate Simple JWT Login CLI add-on is deprecated and no longer needed.

While the add-on is active, the built-in commands are not registered, General > CLI defaults to off, and the CLI card in the admin shows a warning. Deactivate and delete the add-on to switch to the built-in commands. Scripts written for the add-on may need changes - see Migrating from the add-on.

On versions before 4.3.0, the commands are only available through the add-on.

Enable or disable the commands​

The commands are enabled by default. To disable them, turn off Simple JWT Login > General > CLI, or run:

wp jwt config set cli.enabled 0

Once disabled, wp jwt is no longer registered, so it can only be turned back on from the admin.

warning

Anyone who can run WP-CLI on the server can issue a JWT for any user, administrators included (wp jwt generate), and read the signing key (wp jwt config get). Restrict shell access, or disable the commands on servers where WP-CLI access is shared.

Command overview​

CommandDescription
wp jwt setupGenerate a signing key if there is none and enable /auth
wp jwt loginAuthenticate a user with a password and print a JWT
wp jwt generateIssue a JWT for a user without a password
wp jwt refreshExchange a refresh token for a new JWT
wp jwt decodePrint the claims of a JWT (signature not verified)
wp jwt validateVerify signature, expiry, audience, user, and revocation
wp jwt revokeRevoke a JWT and delete the user's refresh tokens
wp jwt revoke-allRevoke every JWT and refresh token of a user
wp jwt key generate / rotatePrint a new signing key, or replace the stored one
wp jwt api-key create / list / revokeManage API keys
wp jwt auth-code list / add / removeManage auth codes
wp jwt config get / set / list / export / importRead and change the settings
wp jwt doctorVersions, REST URLs, endpoint status, and configuration warnings
wp jwt security-reportSecurity score (0-100, grade A-F) and findings
wp jwt explain-errorMeaning, HTTP status and related settings of an error code
wp jwt log list / analyzeQuery and summarize the audit log
wp jwt webhook list / test / logsList webhooks, send a test call, read the call log
wp jwt cleanupRun the daily cleanup job immediately

Conventions​

  • Commands that return a single result accept --format=text (default) or --format=json.
  • Commands that return a list accept --format=table (default), csv, json, yaml or count, and --fields=a,b to select columns.
  • A <user> argument accepts a user ID, login, or email, the same as wp user get.
  • Commands that change data ask for confirmation. Pass --yes to skip the prompt in scripts.
  • Global WP-CLI flags work as usual, for example --url=<site> on Multisite or --path=<dir>.
note

With the audit log enabled, commands that change data are recorded as cli.command.success or cli.command.failed (enable the events in Audit Logs). The entry uses the WordPress user passed with the global --user=<user> flag. A command that disables the audit log is still recorded.

Use cases for teams​

The REST API is built for client applications. The CLI is built for the people who operate the site: developers, DevOps, support, and security. The examples below show where wp jwt replaces manual work in the admin or custom scripts.

Local and preview environments​

A fresh WordPress install needs a signing key and an enabled /auth endpoint before a frontend can log in. wp jwt setup does both, so a docker compose up or a provisioning script produces a working environment without opening the admin.

wp plugin install simple-jwt-login --activate
wp jwt setup --algorithm=HS256
wp jwt config import ./config/jwt.json --merge --yes # project defaults, see "Configuration as code"

CI tests without a stored password​

Integration and end-to-end tests need a valid JWT. With wp jwt generate, the pipeline gets a short-lived token for a dedicated test user, so no WordPress password has to be stored in CI secrets.

TOKEN=$(wp jwt generate ci-bot --ttl=10) # valid for 10 minutes
curl -fsS -H "Authorization: Bearer $TOKEN" \
https://staging.example.com/wp-json/wp/v2/users/me
wp jwt revoke "$TOKEN" # invalidate it when the job ends

Configuration as code​

Keep the plugin settings in the repository and apply them on deploy. Changes go through code review, and --dry-run prints the exact diff (secret values masked) before anything is saved.

# Once, on the reference environment
wp jwt config export --file=config/jwt.json

# In the deploy pipeline
wp jwt config import config/jwt.json --merge --dry-run
wp jwt config import config/jwt.json --merge --yes
warning

The export contains the signing key and other secrets. Remove them from the file before committing it, and set them per environment with wp jwt config set or in wp-config.php. Import such a file with --merge: a full import replaces the whole settings object and would drop the stored keys.

Security checks in CI​

Fail a pipeline when the configuration has critical findings, for example a short signing key or a public endpoint without an auth code.

wp jwt security-report --min-severity=critical --format=json \
| jq -e '.findings | length == 0' > /dev/null \
|| { wp jwt security-report --min-severity=critical; exit 1; }

Scheduled key rotation​

wp jwt key rotate replaces the signing key without invalidating issued tokens: tokens signed before the rotation are accepted until they expire. This makes periodic rotation safe to run from cron.

# crontab: rotate the signing key on the 1st of every month
0 3 1 * * cd /var/www/html && wp jwt key rotate --yes

Incident response​

When a token, a device or a signing key is compromised, the response is a few commands instead of a database edit.

wp jwt revoke-all [email protected] --yes # one user: every JWT and refresh token
wp jwt key rotate --immediate --yes # leaked key: every issued token stops working
wp jwt log analyze --hours=24 # failure rates, top failing IPs and users
wp jwt log list --status=failure --per-page=100 --format=csv > incident.csv

Integrations and partners​

Create a scoped, expiring API key for a partner or a service, and revoke it when the contract ends. The key value is printed once, at creation.

wp jwt api-key create integrations --name="Partner ACME" \
--permissions=read --expires-at="2027-06-30 23:59:59" --format=json
wp jwt api-key list --fields=id,name,key_prefix,expires_at,last_used_at
wp jwt api-key revoke 7

Webhook verification​

Check a webhook URL and its headers before enabling it in production. test sends a test payload even when the webhook is disabled and fails on a non-2xx response.

wp jwt webhook list
wp jwt webhook test 0 --event=login

Support and troubleshooting​

When a client reports an error, the support engineer can check the token and the configuration on the server directly.

wp jwt explain-error 48 # what errorCode 48 means and which settings to check
wp jwt decode "$TOKEN" --format=json # claims, without verifying the signature
wp jwt validate "$TOKEN" # the same checks the endpoints run
wp jwt doctor # endpoints, REST URLs and configuration warnings

Setup​

wp jwt setup​

Prepares a site to issue JWTs: generates a signing key when the configured algorithm has none, enables Authentication, and prints the /auth URL with a sample curl request.

wp jwt setup [--algorithm=<algorithm>] [--force]
OptionRequiredDescription
--algorithm=<algorithm>NoHS256, HS384, HS512, RS256, RS384, RS512, or random. Default: the configured algorithm. A different algorithm always gets a new key
--forceNoGenerate a new key even if one exists

A replaced key keeps validating the tokens it signed until they expire, the same as wp jwt key rotate. Keys defined in wp-config.php are not changed, and in that case the algorithm can not be changed from the command line.

wp jwt setup # keep the existing key, enable /auth
wp jwt setup --algorithm=RS256 # switch to RS256 with a new RSA key pair
wp jwt setup --force # new key, same algorithm

Tokens​

wp jwt login​

Authenticates a WordPress user with a password and prints a JWT.

note

Authentication > Allow Authentication must be enabled, or run wp jwt config set authorization.enabled 1.

wp jwt login [--username=<username>] [--email=<email>] [--login=<login>] [--password=<password>] [--format=<format>]
OptionRequiredDescription
--username=<username>One identifierWordPress username
--email=<email>One identifierWordPress user email
--login=<login>One identifierUsername or email - tried as username first, then as email
--password=<password>NoThe user's password. If omitted, it is read from a hidden prompt or from STDIN, so it does not end up in the shell history
--format=<format>Notext (default) or json

When more than one identifier is passed, the priority is --username > --email > --login. When Refresh Token is enabled, a refresh token is stored the same as on /auth. Users with two-factor authentication can not get a JWT from the command line.

wp jwt login --username=admin # prompts for the password
wp jwt login --email=[email protected] --format=json < password.txt
# {"jwt":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."}

TOKEN=$(wp jwt login --username=admin < password.txt)
curl -H "Authorization: Bearer $TOKEN" https://example.com/wp-json/wp/v2/users/me

wp jwt generate​

Issues a JWT for a user without their password. The token has the same claims and signing key as one from /auth. Two-factor authentication is not applied. When Refresh Token is enabled, a refresh token is printed too.

wp jwt generate <user> [--ttl=<minutes>] [--format=<format>]
OptionRequiredDescription
<user>YesUser ID, login, or email
--ttl=<minutes>NoExpiration in minutes, minimum 1. Defaults to Authentication > JWT TTL
--format=<format>Notext (default) or json. In text format without a refresh token, only the JWT is printed, so the output can be assigned to a variable
TOKEN=$(wp jwt generate admin --ttl=10)
wp jwt generate 42 --format=json
# {"jwt":"eyJ0eXAiOiJKV1Qi...","refresh_token":"3f2a..."}

wp jwt refresh​

Exchanges a refresh token for a new JWT and a new refresh token, like /auth/refresh. The endpoint checks apply. Refresh Token must be enabled, Allowed IPs must be empty (a CLI request has no client IP), and the auth code is required when the endpoint requires one. The old refresh token is invalidated.

wp jwt refresh <refresh-token> [--auth-code=<code>] [--format=<format>]
OptionRequiredDescription
<refresh-token>YesA refresh token from /auth, wp jwt login or wp jwt generate
--auth-code=<code>If the refresh endpoint requires an auth codeThe auth code
--format=<format>Notext (default) or json
wp jwt refresh 3f2a...c9
# jwt eyJ0eXAiOiJKV1Qi...
# refresh_token 8b1d...e4
wp jwt refresh 3f2a...c9 --auth-code=MY_CODE --format=json | jq -r '.jwt'

wp jwt decode​

Prints the payload of a JWT. The signature is not verified - use wp jwt validate for that.

wp jwt decode <token> [--format=<format>]
OptionRequiredDescription
<token>YesThe JWT
--format=<format>Notext (default, one claim value line per claim) or json
wp jwt decode eyJhbGciOiJIUzI1NiJ9.eyJpZCI6MSwiZXhwIjoxOTk5OTk5fQ.sig
# id 1
# exp 1999999

wp jwt decode "$TOKEN" --format=json | jq '.exp'

wp jwt validate​

Validates a JWT with the same checks as the plugin endpoints: JWT rules, signature, expiry, audience, user, and revocation.

wp jwt validate <token> [--format=<format>]
OptionRequiredDescription
<token>YesThe JWT
--format=<format>Notext (default) or json ({"valid":true,"message":"..."})

The exit code is 1 when the token is not valid, so the command can be used directly in if statements and CI steps.

wp jwt validate "$TOKEN"
# valid yes
# message Token is valid.

if wp jwt validate "$TOKEN" > /dev/null; then
echo "Token OK"
fi
tip

validate and revoke need the signing key and algorithm (General), and the Login > Login by setting must match a claim in the token.

wp jwt revoke​

Revokes a JWT. The signature is verified first, and the user's refresh tokens are deleted, the same as the revoke endpoint.

wp jwt revoke <token> [--format=<format>]
OptionRequiredDescription
<token>YesThe JWT to revoke
--format=<format>Notext (default) or json
wp jwt revoke "$TOKEN"
# success yes
# message Token has been revoked.

wp jwt revoke-all​

Revokes every JWT and refresh token issued to a user up to now, for example after a leaked token or a lost device. It works whether or not Revoke tokens on password change is enabled. Tokens issued afterwards (from the next second) are valid.

wp jwt revoke-all <user> [--yes]
OptionRequiredDescription
<user>YesUser ID, login, or email
--yesNoSkip the confirmation prompt
wp jwt revoke-all [email protected] # prompts: "Revoke every token of jane?"
wp jwt revoke-all 42 --yes

wp jwt key​

wp jwt key generate [--algorithm=<algorithm>] [--format=<format>]
wp jwt key rotate [--algorithm=<algorithm>] [--immediate] [--show] [--yes]
OptionCommandDescription
--algorithm=<algorithm>bothHS256, HS384, HS512, RS256, RS384, RS512, or random (the selected algorithm is printed). Default: the configured algorithm
--format=<format>generatetext (default: the key, or the private then the public PEM) or json (algorithm and the key fields)
--immediaterotateDo not keep the old key: every token signed with it, or with a key kept by an earlier rotation, is rejected immediately
--showrotatePrint the new key. Without it, the key is only saved
--yesrotateSkip the confirmation prompt

generate prints a key without saving it: random bytes the size of the hash, hex encoded, for HS256/384/512, or an RSA key pair for RS256 (2048 bits), RS384 (3072 bits) and RS512 (4096 bits).

rotate saves a new key (and a new algorithm, with --algorithm) without breaking issued tokens:

  1. New tokens are signed with the new key.
  2. The old key is moved to a JWT Rule that matches tokens with iat less than the rotation time, so tokens issued before the rotation stay valid until they expire.
  3. The daily cleanup (or wp jwt cleanup, or the next rotation) removes that rule once the JWT TTL plus 60 seconds has passed.

Refresh tokens keep working: when no Refresh Token key is set, the old key becomes the refresh token key. Your own JWT rules are not changed and are evaluated before the rotation rules. A key defined in wp-config.php must be changed there.

warning

Until its rule is removed, the old key still validates tokens. If a key leaked, use --immediate.

Tokens that live longer than the JWT TTL (wp jwt generate --ttl, or a payload without exp) stop working when the rule is removed.

wp jwt key generate --algorithm=HS512 # print a key to use elsewhere
wp jwt key generate --algorithm=RS256 --format=json # RSA key pair as JSON
wp jwt key rotate --yes # scheduled rotation, issued tokens stay valid
wp jwt key rotate --algorithm=RS256 --show # switch to RS256 and print the key pair
wp jwt key rotate --immediate --yes # leaked key: reject every issued token now

wp jwt api-key​

wp jwt api-key create <owner> --name=<name> --permissions=<list> [--expires-at=<date>] [--format=<format>]
wp jwt api-key list [--page=<n>] [--per-page=<n>] [--fields=<fields>] [--format=<format>]
wp jwt api-key revoke <id>
OptionCommandRequiredDescription
<owner>createYesUser ID, login, or email of the key owner. The owner's capabilities apply, as in the admin: a user can only grant permissions they have
--name=<name>createYesA label for the key, for example CI deploy
--permissions=<list>createYesComma separated: read, create, update, delete
--expires-at=<date>createNoExpiration date, Y-m-d H:i:s in UTC. Default: no expiration
--format=<format>createNotext (default) or json
--page=<n>listNoPage number. Default: 1
--per-page=<n>listNoKeys per page. Default: 100
--fields=<fields>listNoDefault: id,user_id,name,key_prefix,permissions,expires_at,last_used_at,revoked_at
--format=<format>listNotable (default), csv, json, yaml or count
<id>revokeYesThe key ID from list. A revoked key stays in the list with its revoked_at date

The key value is printed only once, at creation. list shows the prefix only. See API Keys for how the keys are used.

wp jwt api-key create admin --name="CI deploy" --permissions=read --format=json
wp jwt api-key create 42 --name="Mobile app" --permissions=read,create,update --expires-at="2027-01-31 23:59:59"
wp jwt api-key list --fields=id,name,key_prefix,revoked_at
wp jwt api-key revoke 3

wp jwt auth-code​

wp jwt auth-code list [--show] [--fields=<fields>] [--format=<format>]
wp jwt auth-code add [<code>] [--role=<role>] [--expires=<date>]
wp jwt auth-code remove <index> [--yes]
OptionCommandRequiredDescription
--showlistNoPrint the codes. Without it, they are masked
--fields=<fields>listNoDefault: index,code,role,expiration_date
--format=<format>listNotable (default), csv, json, yaml or count
<code>addNoThe code. If omitted, a random code is generated and printed once
--role=<role>addNoRole assigned to users who register with this code. Default: the Register setting
--expires=<date>addNoExpiration date, for example 2027-01-31 23:59:59. Default: no expiration
<index>removeYesThe code's index from list
--yesremoveNoSkip the confirmation prompt

See Auth Codes for where the codes are checked.

wp jwt auth-code add --role=subscriber # random code, printed once
wp jwt auth-code add MY_CODE --expires="2027-01-31 23:59:59"
wp jwt auth-code list --show
wp jwt auth-code remove 0 --yes

Settings​

Setting keys use dot notation, with the section first: general.jwt_algorithm, authorization.ttl, cors.enabled. wp jwt config list prints every key.

wp jwt config get​

Prints one setting. Array values are printed as JSON.

wp jwt config get <key> [--format=<format>]
OptionRequiredDescription
<key>YesSetting key in dot notation, for example cors.enabled
--format=<format>Notext (default) or json (the JSON-encoded value, for example "HS256" or true)
wp jwt config get authorization.enabled
# 1
wp jwt config get authorization.jwt_payload --format=json
# ["iat","exp","id"]

wp jwt config set​

Changes a setting. The resulting settings are validated the same way as a save from the admin page. Nothing is saved when validation fails.

wp jwt config set <key> <value> [--type=<type>] [--force]
OptionRequiredDescription
<key>YesSetting key in dot notation, inside a section (general.jwt_algorithm, not jwt_algorithm)
<value>YesThe new value. Booleans accept 1, true, yes and on; anything else is false
--type=<type>Noauto (default), string, int, bool or json
--forceNoSkip validation and save anyway. Use it only to repair settings that can not be fixed otherwise

With --type=auto, the type follows the stored value: a boolean stays a boolean, an integer stays an integer, and an array expects a JSON string. A key without a stored value is saved as a string.

wp jwt config set authorization.enabled 1
wp jwt config set general.jwt_algorithm RS256
wp jwt config set authorization.ttl 120 --type=int
wp jwt config set general.decryption_key "my-super-secret"
wp jwt config set authorization.jwt_payload '["iat","exp","id","email"]' --type=json

wp jwt config list​

wp jwt config list [--format=<format>]
OptionRequiredDescription
--format=<format>Notext (default): one key value line per setting, arrays as JSON. json: the full settings object
warning

list and get print secrets, such as the signing key, in plain text.

wp jwt config list
# authorization.enabled 1
# general.jwt_algorithm HS256
# ...

wp jwt config export​

Prints all settings as JSON, or writes them to a file, for backups or for import on another site.

wp jwt config export [--file=<path>]
OptionRequiredDescription
--file=<path>NoWrite the JSON to this file instead of STDOUT. The file is created with 0600 permissions
warning

The export contains secrets such as the signing key. Store the file accordingly.

wp jwt config export --file=jwt-config.json
wp jwt config export | jq '.general.jwt_algorithm'

wp jwt config import​

Imports settings from a JSON file created by wp jwt config export. By default, the whole settings object is replaced; --merge changes only the keys present in the file. The command prints a diff ([+] added, [~] changed, [-] removed; secret values are masked) and asks for confirmation before saving.

wp jwt config import <file> [--merge] [--dry-run] [--yes] [--force]
OptionRequiredDescription
<file>YesPath to the JSON file
--mergeNoMerge into the current settings instead of replacing them. Lists (for example authorization.jwt_payload) are replaced, not merged
--dry-runNoPrint the diff without saving
--yesNoSkip the confirmation prompt
--forceNoSkip validation and save anyway

A full export from Simple JWT Login 3.x is converted to the 4.x format on import.

# Copy the configuration from one site to another
wp jwt config export --file=jwt-config.json # source site
wp jwt config import jwt-config.json --dry-run # target site: preview
wp jwt config import jwt-config.json --yes # target site: apply

# Change a few settings from a partial file
echo '{"cors":{"enabled":1}}' > cors.json
wp jwt config import cors.json --merge --yes

The same configuration can be exported and imported from the admin - see Export and Import.

Diagnostics, logs, and webhooks​

wp jwt doctor​

Checks the installation: plugin, WordPress and PHP versions, the REST URLs, each endpoint (enabled, auth code required), the JWT settings, and configuration warnings. Run it first when something does not work.

wp jwt doctor [--format=<format>]
OptionRequiredDescription
--format=<format>Notext (default: summary, endpoint table and warnings table) or json
wp jwt doctor
wp jwt doctor --format=json | jq '.warnings'

wp jwt security-report​

Scores the configuration from 0 to 100 (grade A-F) and lists the findings, for example a short signing key or a missing auth code. The Dashboard shows the same critical and warning findings.

wp jwt security-report [--min-severity=<severity>] [--fields=<fields>] [--format=<format>]
OptionRequiredDescription
--min-severity=<severity>NoLowest severity to list: info (default), warning or critical
--fields=<fields>NoFinding columns in the text table. Default: severity,code,message,settings
--format=<format>Notext (default) or json (score, grade, counts, findings)
wp jwt security-report
# Score: 80/100 (grade B)
wp jwt security-report --min-severity=warning --format=json
wp jwt security-report --fields=severity,message

wp jwt explain-error​

Explains an error code from an API response ("errorCode": 48) or a settings save: what it means, the HTTP status, and the settings to check. The full list is in Error Codes.

wp jwt explain-error <code> [--format=<format>]
OptionRequiredDescription
<code>YesThe error code
--format=<format>Notext (default) or json
wp jwt explain-error 48
# constant ERR_AUTHENTICATION_WRONG_CREDENTIALS
# http_status 401
# explanation Wrong username/email or password. ...

wp jwt log​

Reads the audit log. Audit Logs must be enabled for new entries to be recorded; existing entries can be read when it is off.

wp jwt log list [--event-type=<event>] [--status=<success|failure>] [--user-id=<id>] [--page=<n>] [--per-page=<n>] [--fields=<fields>] [--format=<format>]
wp jwt log analyze [--hours=<hours>] [--format=<format>]
OptionCommandDescription
--event-type=<event>listFilter by event, for example auth.login.failed or cli.command.success
--status=<status>listsuccess or failure
--user-id=<id>listFilter by user ID
--page=<n>listPage number. Default: 1
--per-page=<n>listEntries per page, maximum 100. Default: 20
--fields=<fields>listDefault: id,created_at,event_type,status,user_id,ip_address,message
--format=<format>listtable (default), csv, json, yaml or count
--hours=<hours>analyzeTime window in hours. Default: 24
--format=<format>analyzetext (default) or json

list returns entries newest first. analyze reports failure rates per event, the top failing IPs, users and API keys, and findings such as brute-force patterns.

wp jwt log list --status=failure --per-page=50
wp jwt log list --event-type=auth.login.failed --user-id=42 --format=csv > failed-logins.csv
wp jwt log list --event-type=cli.command.success --fields=created_at,user_id,message
wp jwt log list --status=failure --format=count
wp jwt log analyze --hours=168 # last 7 days

wp jwt webhook​

wp jwt webhook list [--event=<event>] [--fields=<fields>] [--format=<format>]
wp jwt webhook test <index> [--event=<event>]
wp jwt webhook logs [--event=<event>] [--page=<n>] [--per-page=<n>] [--fields=<fields>] [--format=<format>]
OptionCommandDescription
--event=<event>listFilter by event, for example login
--fields=<fields>listDefault: index,enabled,method,url,events. Header values are never printed
--format=<format>list, logstable (default), csv, json, yaml or count
<index>testThe webhook index from list
--event=<event>testEvent sent in the test payload. Default: the webhook's first event
--event=<event>logsFilter by event
--page=<n>logsPage number. Default: 1
--per-page=<n>logsEntries per page. Default: 20
--fields=<fields>logsDefault: id,created_at,event,method,url,status_code

test sends a test payload to the webhook immediately, even when the webhook or webhooks in general are disabled, and prints the response. It fails on a non-2xx response. The call is logged when Webhook logs are enabled. logs lists recorded calls, newest first, and requires Webhook logs. See Webhooks.

wp jwt webhook list --event=login
wp jwt webhook test 0
wp jwt webhook test 0 --event=register
wp jwt webhook logs --event=login --per-page=50

wp jwt cleanup​

Runs the daily cleanup immediately instead of waiting for WP-Cron. It deletes expired refresh tokens and revoked tokens, log entries older than their retention period, and signing keys kept by wp jwt key rotate once their tokens have expired. It takes no options.

wp jwt cleanup

Migrating from the add-on​

  1. Update Simple JWT Login to 4.3.0 or later.
  2. Deactivate and delete the Simple JWT Login CLI plugin (find its slug with wp plugin list).
  3. If General > CLI is off, turn it on.
  4. Check wp jwt --help.

Then review scripts written for the add-on:

ChangeAdd-onBuilt-in (4.3.0+)
wp jwt validate exit codeAlways 0; scripts parsed the valid field1 when the token is not valid
wp jwt login --passwordRequiredOptional; read from a hidden prompt or STDIN
wp jwt config set / importSaved without validationValidated like an admin save; --force skips it
Setting keys3.x namesSection-prefixed 4.x names (see below)

A 3.x key fails with an error that names the new key:

3.x4.x
allow_authenticationauthorization.enabled
jwt_auth_ttlauthorization.ttl
jwt_payloadauthorization.jwt_payload
jwt_algorithmgeneral.jwt_algorithm
decryption_keygeneral.decryption_key
jwt_login_bylogin.login_by
jwt_login_by_parameterlogin.login_by_parameter

Troubleshooting​

ErrorCauseFix
'jwt' is not a registered wp commandThe CLI is disabled, or the old add-on is activeEnable General > CLI, or deactivate the add-on
Authentication is not enabled.The Authentication section is disabledwp jwt config set authorization.enabled 1
Wrong user credentials.Wrong username, email, or passwordCheck the credentials
Please provide --username, --email, or --loginNo identifier was passedAdd --username, --email or --login
Please provide --passwordNo password was passed or enteredPass --password, enter it at the prompt, or pipe it on STDIN
User not found: <user>No user has this ID, login, or emailCheck with wp user get <user>
This user must complete two-factor authentication.The user has 2FA enabledA JWT can not be created from the command line for this user
Could not decode token. ...The token does not have three dot-separated partsPass the full token
valid: no (exit code 1)wp jwt validate rejected the tokenThe message field contains the reason, for example an expired token or a bad signature
The signing key is defined in wp-config.php. ...key rotate with the key defined in codeChange the constants in wp-config.php
You are not allowed to Authenticate from this IPrefresh with Allowed IPs setA CLI request has no client IP; refresh over HTTP
Token has already been revoked.The token was already revokedNo action needed
User not found.No WordPress user matches the tokenMake sure the token was issued for an existing user
Unable to find user <claim> property in JWT.The Login by claim is not in the payloadIssue a new token, or change Login > Login by
Setting <key> is now <new key>.A 3.x key was usedUse the 4.x key
Validation failed: ...The new settings are not validFix the value, or pass --force
Setting "<key>" not found.The key has no stored valueThe plugin default applies; set stores a value
The current value is an array. ...An array setting was set without JSONPass --type=json with a JSON array or object
Invalid JSON value: ... / Invalid JSON in <file>: ...Malformed JSONCheck it with jq . first
Cannot read file: <path>The file does not exist or is not readableCheck the path and permissions
No changes detected.The file matches the stored settingsNo action needed

Next steps​