Tmeister / wp-api-jwt-auth

A simple plugin to add JSON Web Token (JWT) Authentication to WP REST API
GNU General Public License v2.0
556 stars 160 forks source link

invalid_username at token/validate #297

Closed devdanielsun closed 8 months ago

devdanielsun commented 8 months ago

invalid_username at token/validate

Prerequisites

Context

Expected Behavior

/wp-json/jwt-auth/v1/token/validate

Http status: 200

/wp-json/wp/v2/users

Http status: 200

Current Behavior

/wp-json/jwt-auth/v1/token/validate

Http status: 500 Internal Server Error

{
    "code": "invalid_username",
    "message": "<strong>Error:</strong> The username <strong>{\"typ\"</strong> is not registered on this site. If you are unsure of your username, try your email address instead.",
    "data": null
}

but....

/wp-json/wp/v2/users

Http status: 200

Failure Information (for bugs)

/wp-json/jwt-auth/v1/token?username=user&password=secret

Is working and gets me the token. But trying to validate does not work...

.htaccess file

#Begin JWT auth
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
</IfModule>
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
#End JWT auth

And the wp-config.php also contains:

define('JWT_AUTH_SECRET_KEY', 'secret-hash');
define('JWT_AUTH_CORS_ENABLE', true);
devdanielsun commented 8 months ago

Fixed it by removing some other plugins....