Support » Plugin: JWT Authentication for WP REST API » How to fix error ‘The password you entered for the username ***** is incorrect’?

  • I want to get a token using this code:

    curl_setopt($ch, CURLOPT_URL, ‘https://********/wp-json/jwt-auth/v1/token?username=enews&password=*************’);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    $result = curl_exec($ch);
    $result_decoded = (array)json_decode($result);


    And I get this error:

    Array ( [code] => [jwt_auth] incorrect_password [message] => ERROR: The password you entered for the username enews is incorrect. Lost your password? [data] => stdClass Object ( [status] => 403 ) )

    But the password is correct, I have logged in wp-admin many times with this user and pass. What can be the problem?
    I have installed jwt auth , I have added
    RewriteEngine On
    RewriteCond %{HTTP:Authorization} ^(.*)
    RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
    to .htaccess
    define('JWT_AUTH_SECRET_KEY', '*********************************************************');

    to wp_config.php What am I missing? Thank you!

Viewing 1 replies (of 1 total)
  • I am not the plugin author.
    I think that had similar problem. I was sending the parameters in the body in json format.
    The code expects raw format.

    I ended up modifying the code as follows:
    in file wp-content\plugins\jwt-authentication-for-wp-rest-api\public\class-jwt-auth-public.php
    look for function public function generate_token($request){

    At the beginning:

    $secret_key = defined('JWT_AUTH_SECRET_KEY') ? JWT_AUTH_SECRET_KEY : false;
            $username = $request->get_param('username'); 
            $password = $request->get_param('password');
            if ($username == "" || $password == "") { // try json format
                $body = $request->get_body(); // $request->get_param('body');
                $json = json_decode( $body, true );
                $username = $json['body']['username'];
                $password = $json['body']['password'];

    I have added the if statement with comment “// try json format”

    My guess is that your request is not parsed properly, so password in incorrect…
    Note that 1. this is a guess 2. my solution is not elegantbut does thw work in my case

Viewing 1 replies (of 1 total)
  • The topic ‘How to fix error ‘The password you entered for the username ***** is incorrect’?’ is closed to new replies.