Refresh an expired JWT
POST/auth/refresh
Exchanges a valid refresh token for a new JWT (and a new refresh token). The original refresh token is single-use: when several requests send the same token at once, only one of them gets a new JWT, the others answer "Invalid refresh token."
Requirements
- The refresh-token feature must be enabled in the plugin settings.
- The refresh token must exist in the database and not have exceeded the maximum token age configured in the plugin settings.
- Authentication must be enabled in the plugin settings.
- If "Refresh Token Requires Auth Code" is enabled,
AUTH_KEYmust be provided. - If a JWT is also sent (header, cookie, session or
JWTparameter) and it has been revoked, the request is rejected. Any other problem with that JWT (for example, expired) is ignored.
Custom payload claims
Optionally supply payload as a JSON-encoded object to add extra claims to the
newly issued JWT. Reserved identity claims are always derived from the
authenticated user and cannot be overridden this way.
Request
Responses
- 200
- 400
- 401
- 403
- 422
- 500
JWT refreshed successfully. Returns a new JWT and a new refresh token.
The new JWT could not be signed (JWT library error, for example, OpenSSL signing failure
error_code 16).
Unauthorized. One of:
- The refresh token was not found in the database (expired, already rotated,
or never issued) (
error_code51). - A JWT was supplied alongside the refresh token but has been revoked -
revoked JWTs cannot be used to obtain new tokens (
error_code55). - The WordPress user linked to the refresh token no longer exists
(
error_code55). - The provided auth code is wrong (
error_code27).
Forbidden. One of:
- The refresh-token feature is disabled in the plugin settings (
error_code81). - Authentication is disabled in the plugin settings (
error_code45). - The client IP address is not on the allow-list (
error_code41).
Unprocessable entity. One of:
- The
refresh_tokenfield is absent from the request (error_code51). - The auth code is required but was not provided (
error_code94).
The new refresh token could not be saved in the database (error_code 131).
The old refresh token is already used up, so the client must log in again.