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

Notice: register_rest_route was called incorrectly. #207

Closed rajweb closed 1 year ago

rajweb commented 4 years ago

Wordpress Version: 5.5 WooCommerce Version: 4.3.3

i got below notic in woocommerce section of admin panel:

1- Notice: register_rest_route was called incorrectly. The REST API route definition for jwt-auth/v1/token is missing the required permission_callback argument. For REST API routes that are intended to be public, use __return_true as the permission callback. Please see Debugging in WordPress for more information. (This message was added in version 5.5.0.) in /home/rajkamal/public_html/test_wp/wp-includes/functions.php on line 5225.

2- Notice: register_rest_route was called incorrectly. The REST API route definition for jwt-auth/v1/token/validate is missing the required permission_callback argument. For REST API routes that are intended to be public, use __return_true as the permission callback. Please see Debugging in WordPress for more information. (This message was added in version 5.5.0.) in /home/rajkamal/public_html/test_wp/wp-includes/functions.php on line 5225

thanks in advance

mvdhoek1 commented 4 years ago

I was trying to open a pull-request but obviously I do not have the correct access rights.

Below should do the trick

    /**
     * Add the endpoints to the API
     */
    public function add_api_routes()
    {
        register_rest_route($this->namespace, 'token', array(
            'methods' => 'POST',
            'callback' => array($this, 'generate_token'),
            'permission_callback' => __return_true(),
        ));

        register_rest_route($this->namespace, 'token/validate', array(
            'methods' => 'POST',
            'callback' => array($this, 'validate_token'),
            'permission_callback' => __return_true(),
        ));
    } 
simplenotezy commented 4 years ago

Created a pull request here: https://github.com/Tmeister/wp-api-jwt-auth/pull/209

velara3 commented 4 years ago

Was receiving the same error. Some general advice.

Should I add this to my plugin directly or wait until a release? If I add it (for now) will it be ok when a new release containing this change is out and that update will overwrite it (or cause update errors)?

jnz31 commented 3 years ago

Was receiving the same error. Some general advice.

Should I add this to my plugin directly or wait until a release? If I add it (for now) will it be ok when a new release containing this change is out and that update will overwrite it (or cause update errors)?

you can add it manually. on plugin update, this would be overwritten.

pondermatic commented 3 years ago

According to REST API changes in WordPress 5.5, pull request #209 fixes this issue correctly.

rponline commented 3 years ago

Just got the same error and can confirm that PR #209 fixes the issue. I would love to see it in the next update!

hideki-masuoka commented 3 years ago

Hope! next version. I created a fix plugin while waiting for the next version. (Google translate) GitHub - hideki-masuoka/quiet-wp-api-jwt-auth: Fix > Notice: register_rest_route was called incorrectly. #207

pglewis commented 2 years ago

This was reported over a year ago, it's a very simple fix, and even has a proper PR #209. Is there a reason for the hold up?

vncafecode commented 2 years ago

It's December 2021 and the PR is still in review? I have the same issue and have to manually edit the plugin files.

lkraav commented 2 years ago

It's increasingly looking like this code is abandonware :( Is anyone here aware of any current alternatives?

lkraav commented 2 years ago

What about https://github.com/usefulteam/jwt-auth which seems to be adequately maintained.