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
549 stars 159 forks source link

Unable to authenticate with username & password #230

Closed dbcoder14 closed 2 years ago

dbcoder14 commented 2 years ago

Hi, After following the complete guideline provided at https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/; my authentication request still fails.

Following is the example of curl:

curl --location --request POST 'https://mydomain.dk/wp-json/jwt-auth/v1/token' \
  --header 'Content-Type: application/json' \
  --data-raw '{
      "username": "email,
      "password": "2passwoed"
  }'

The username and password are valid, and I am successfully able to login in /wp-admin, but following is the error response I am receiving:

{
    "code": "rest_login_required",
    "message": "REST API restricted to authenticated users.",
    "data": {
        "status": 401
    }
}

.htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
</IfModule>

Seems like jwt-auth/v1/token are not publically accessible, any hint?

dbcoder14 commented 2 years ago

The issue is resolved, rest api was block by other plugin.