Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi Mr. Bagus,
    Thanks helping me out for information.

    – I am using Theme.
    – With in function.php only i am initializing “rest_api_init”
    – Added the “add_filter(‘jwt_auth_whitelist’, function ( $endpoints )” before initializing rest_API_init.
    – but still facing issue.

    Getting above error for while creating blogs from admin panel itself. For custom end point with authentication token working fine with your plugin.

    I am new to WordPress, please guide me in whitelisting the default API / routes which i mentioned in above query.

    Following is the sequence of my code implementation:

    add_filter(‘jwt_auth_whitelist’, function ( $endpoints ) {
    return array(
    ‘/wp-json/wp/v2/*’,
    ‘/wp-json/yoast/v1/*’,
    ‘/wp-json/wpcom/v2/*’,
    ‘/wp-json/wp/v1/*’,
    ‘/wp-json/jetpack/v4/*’
    );
    });

    /*
    * Creating Custom End POint
    * API )
    */

    add_action(‘rest_api_init’, function () {
    register_rest_route(‘wp/v1’, ‘allposts’, array(
    ‘methods’ => ‘GET’,
    ‘callback’ => ‘get_latest_post’
    ));
    register_rest_route(‘wp/v1’, ‘getPostByKey’, array(
    ‘methods’ => ‘GET’,
    ‘callback’ => ‘get_post_By_Key’
    ));
    register_rest_route(‘wp/v1’, ‘getThemeBlogs’, array(
    ‘methods’ => ‘GET’,
    ‘callback’ => ‘get_theme_blogs’
    ));
    });

    Hi Mr. Bagus,
    Thanks for quick response.

    Could you please provide the sample working code for my reference.

    Hi Mr Bagus,
    I am also facing same issue, white listed routes been authenticated.

    add_filter(‘jwt_auth_whitelist’, function ( $endpoints ) {
    return array(
    ‘/wp-json/wp/v2/*’,
    ‘/wp-json/yoast/v1/*’,
    ‘/wp-json/wpcom/v2/*’,
    ‘/wp-json/wp/v1/*’,
    ‘/wp-json/jetpack/v4/*’
    );
    });

    But still authenticating the whitelisted route. getting following error

    {“success”:false,”statusCode”:403,”code”:”jwt_auth_no_auth_header”,”message”:”Authorization header not found.”,”data”:[]}

Viewing 3 replies - 1 through 3 (of 3 total)