Notice: register_rest_route was called incorrectly.
rajweb opened this issue ยท 11 comments
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
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(),
));
}
Created a pull request here: #209
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)?
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.
According to REST API changes in WordPress 5.5, pull request #209 fixes this issue correctly.
Just got the same error and can confirm that PR #209 fixes the issue.
I would love to see it in the next update!
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
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?
It's December 2021 and the PR is still in review? I have the same issue and have to manually edit the plugin files.
It's increasingly looking like this code is abandonware :( Is anyone here aware of any current alternatives?
What about https://github.com/usefulteam/jwt-auth which seems to be adequately maintained.