• It seems like this plugin is throwing a notice in WP 5.5 because it doesn’t set the new permission argument when defining the rest endpoints.
    here is the full error:

    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 xxxxxxx/wp-includes/functions.php on line 5225

    I suggest you update the file
    jwt-authentication-for-wp-rest-api/public/class-jwt-auth-public.php

    to add
    'permission_callback' => __return_true()

    to the arguments of both calls to

    register_rest_route()

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello,

    Thanks for the information, its not working when I have added it to the jwt class file, I have custom endpoints and set the permission callback to is_user_logged_in but its not authenticating the user. This is one of my custom endpoint whic

    register_rest_route( ‘grocery/v1/customer’, ‘my_account/get_address_book’, array(
    ‘methods’ => WP_REST_Server::READABLE,
    ‘callback’ => array( ‘GenerateWP_Grocery_Products_REST_API_Endpoints’, ‘grocery_get_customer_address_book’ ),
    ‘permission_callback’ => function($request){
    return is_user_logged_in();
    },
    ) );

    I am looking for the solution its correctly working on my local system, but when uploading on the server its giving

    {
    “code”: “rest_forbidden”,
    “message”: “Sorry, you are not allowed to do that.”,
    “data”: {
    “status”: 401
    }
    }

    error, I am not getting what will be the issue, I have checked all the error logs but found nothing, please help me in this, your help will be appreciated.

    Thanks

    Please help me I getting issues on all my sites for authorization’

    Thanks in advance

    Thread Starter phy9pas

    (@phy9pas)

    Apologies, my suggested fix was not quite right.
    permission_callback should be string containing the function name, rather than a reference to the function itself.
    e.g.

    'permission_callback' => "__return_true"
    or

    'permission_callback' => "is_user_logged_in"

    Thanks

    But still this fix is not working, I have my custom endpoints, which are not get authenticated on the server, its working very well on the localhost with authorization.
    Please suggest if any edits, I have googled many things but nothing found.

    Many Thanks

    Thread Starter phy9pas

    (@phy9pas)

    Sorry I don’t have anything else to suggest.
    I would probably try using a different plugin for authentication. It seems like this one isn’t maintained any more and the author doesn’t reply to support requests either.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘jwt-auth/v1/token is missing the required permission_callback’ is closed to new replies.