Title: Whitelisting Endpoints function do not work
Last modified: June 29, 2020

---

# Whitelisting Endpoints function do not work

 *  Resolved [careerbuggy](https://wordpress.org/support/users/careerbuggy/)
 * (@careerbuggy)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/whitelisting-endpoints-function-do-not-work/)
 * I tried to create Whitelisting Endpoints function as mentioned still I get same
   error saying JWT authorization is not found error.

Viewing 15 replies - 1 through 15 (of 26 total)

1 [2](https://wordpress.org/support/topic/whitelisting-endpoints-function-do-not-work/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/whitelisting-endpoints-function-do-not-work/page/2/?output_format=md)

 *  Thread Starter [careerbuggy](https://wordpress.org/support/users/careerbuggy/)
 * (@careerbuggy)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/whitelisting-endpoints-function-do-not-work/#post-13051725)
 * could anyone help me in whitelisting the endpoints. it would be a great help.
 *  Plugin Author [Bagus](https://wordpress.org/support/users/contactjavas/)
 * (@contactjavas)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/whitelisting-endpoints-function-do-not-work/#post-13051965)
 * Hi [@careerbuggy](https://wordpress.org/support/users/careerbuggy/) , sorry i
   just see your tickets.
    Didn’t understand why new tickets doesn’t directly come
   to my inbox.
 * Could you please paste your whitelisting code here?
 * Thanks for your question,
    Bagus
 *  [giriposhaneshwar](https://wordpress.org/support/users/giriposhaneshwar/)
 * (@giriposhaneshwar)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/whitelisting-endpoints-function-do-not-work/#post-13054497)
 * 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”:[]}
 *  Plugin Author [Bagus](https://wordpress.org/support/users/contactjavas/)
 * (@contactjavas)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/whitelisting-endpoints-function-do-not-work/#post-13054618)
 * Hi [@giriposhaneshwar](https://wordpress.org/support/users/giriposhaneshwar/),
   thanks for reporting,
    I’m checking it now, will get back to you asap.
 * Bagus
 *  Plugin Author [Bagus](https://wordpress.org/support/users/contactjavas/)
 * (@contactjavas)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/whitelisting-endpoints-function-do-not-work/#post-13054731)
 * Hi [@careerbuggy](https://wordpress.org/support/users/careerbuggy/) & [@giriposhaneshwar](https://wordpress.org/support/users/giriposhaneshwar/),
   thanks for waiting 🙂
 * I’ve tested it. Here is the result:
    – adding the filter directly (without hook)
   works – adding the filter inside `plugins_loaded` also works – adding the filter
   inside `init` **didn’t work** – that means, adding the filter after `init` hook
   will also not work.
 * Please check your code, did you add the filter inside `init` hook (or hooks after
   it)? If so, please change it by adding the filter directly. Or if you want to
   add it inside hook, please use `plugins_loaded` instead.
 * Please let me know if that works for you 🙂
 * Thanks!
    Bagus
 *  [giriposhaneshwar](https://wordpress.org/support/users/giriposhaneshwar/)
 * (@giriposhaneshwar)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/whitelisting-endpoints-function-do-not-work/#post-13054782)
 * Hi Mr. Bagus,
    Thanks for quick response.
 * Could you please provide the sample working code for my reference.
 *  Plugin Author [Bagus](https://wordpress.org/support/users/contactjavas/)
 * (@contactjavas)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/whitelisting-endpoints-function-do-not-work/#post-13054866)
 * Hi [@giriposhaneshwar](https://wordpress.org/support/users/giriposhaneshwar/),
   this is just your code
 *     ```
       add_filter(
       	'jwt_auth_whitelist',
       	function ( $endpoints ) {
       		'/wp-json/wp/v2/*',
       		'/wp-json/yoast/v1/*',
       		'/wp-json/wpcom/v2/*',
       		'/wp-json/wp/v1/*',
       		'/wp-json/jetpack/v4/*',
       	}
       );
       ```
   
 * Just add it without hook. Or simply put it in your `functions.php` (if you use
   theme).
    After that, please also clear your cache if you use `GET` request.
 * Please let me know if that works.
    Thanks, Bagus
 *  [giriposhaneshwar](https://wordpress.org/support/users/giriposhaneshwar/)
 * (@giriposhaneshwar)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/whitelisting-endpoints-function-do-not-work/#post-13054950)
 * 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’ )); });
 *  Plugin Author [Bagus](https://wordpress.org/support/users/contactjavas/)
 * (@contactjavas)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/whitelisting-endpoints-function-do-not-work/#post-13055043)
 * Hi [@giriposhaneshwar](https://wordpress.org/support/users/giriposhaneshwar/),
   would you mind to share your files to [contactjavas@gmail.com](https://wordpress.org/support/topic/whitelisting-endpoints-function-do-not-work/contactjavas@gmail.com?output_format=md)?
   Could be FTP or zip file. Would be easier to see your issue more detail 🙂
 * Thanks,
    Bagus
 *  [rozv](https://wordpress.org/support/users/rozv/)
 * (@rozv)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/whitelisting-endpoints-function-do-not-work/#post-13056490)
 * hello,
    I am having the same issue with whitelist filter not working.
 * my functions.php
 *     ```
       add_filter(
       		'jwt_auth_whitelist',
       		'my_endpoints'
       	);
   
       	function my_endpoints($endpoints) {
       		$endpoints[] = '/wp-json/test/';
       		return $endpoints;
       	}
       ```
   
 * testing in the plugin file class-auth.php i put a var dump and the whitelist 
   is still empty. some how not applying the filter
 *     ```
       $whitelist = apply_filters( 'jwt_auth_whitelist', array() );
       		var_dump($whitelist);
       ```
   
 * i also tried with the jwt_auth_default_whitelist filter, but it didn’t work either..
   Any help would be appreciated! thanks!
 *  Plugin Author [Bagus](https://wordpress.org/support/users/contactjavas/)
 * (@contactjavas)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/whitelisting-endpoints-function-do-not-work/#post-13056502)
 * Hi [@rozv](https://wordpress.org/support/users/rozv/) , I’m testing this filter.
   I use to put the filter in the plugin. I’ll try this in the theme. Will get back
   here in minutes.
 * Thanks a lot for reporting,
    Bagus
 *  Plugin Author [Bagus](https://wordpress.org/support/users/contactjavas/)
 * (@contactjavas)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/whitelisting-endpoints-function-do-not-work/#post-13056543)
 * Hi [@rozv](https://wordpress.org/support/users/rozv/) , i’ve tested (by moving
   the filter from plugin to theme’s functions.php) and it works both on parent &
   child theme. I need more info from you:
 * – What is the full url that is facing this issue? Is it simply this _site.com/
   wp-json/test/_?
    – You simply put it in functions.php right? without putting 
   it into any hook. (just to make sure) – Is it possible for you to provide demo
   site for me? Would be easier if i can check it directly. If possible, you can
   contact me at [contactjavas@gmail.com](https://wordpress.org/support/topic/whitelisting-endpoints-function-do-not-work/contactjavas@gmail.com?output_format=md)
 * Thanks,
    Bagus
 *  Plugin Author [Bagus](https://wordpress.org/support/users/contactjavas/)
 * (@contactjavas)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/whitelisting-endpoints-function-do-not-work/#post-13056589)
 * Hi [@careerbuggy](https://wordpress.org/support/users/careerbuggy/) , [@giriposhaneshwar](https://wordpress.org/support/users/giriposhaneshwar/),
   and [@rozv](https://wordpress.org/support/users/rozv/)
    In case you need faster
   response, here’s [Discord invite link](https://discord.gg/SHj5GA).
 * With discord, i’m always notified.
 *  Plugin Author [Bagus](https://wordpress.org/support/users/contactjavas/)
 * (@contactjavas)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/whitelisting-endpoints-function-do-not-work/#post-13059233)
 * Hi [@careerbuggy](https://wordpress.org/support/users/careerbuggy/) & [@rozv](https://wordpress.org/support/users/rozv/),
   
   In case you’re still facing this problem, here is the fix:
    1. Make sure the filter is added directly without hook
    2. If you’re adding the filter through theme (like in functions.php), and doing
       step above still doesn’t work, then you need move the filter from theme to a
       plugin. Maybe create a 1 file plugin which contains the filter?
 * Please let me know if that works.
    Or maybe [Join discord channel](https://discord.gg/SHj5GA)
   for faster response.
 * Best,
    Bagus
 *  [rozv](https://wordpress.org/support/users/rozv/)
 * (@rozv)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/whitelisting-endpoints-function-do-not-work/#post-13061190)
 * [@contactjavas](https://wordpress.org/support/users/contactjavas/) thank you 
   for all your help! after trying different things, it worked as a separate plugin.
   thanks!

Viewing 15 replies - 1 through 15 (of 26 total)

1 [2](https://wordpress.org/support/topic/whitelisting-endpoints-function-do-not-work/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/whitelisting-endpoints-function-do-not-work/page/2/?output_format=md)

The topic ‘Whitelisting Endpoints function do not work’ is closed to new replies.

 * ![](https://ps.w.org/jwt-auth/assets/icon-256x256.png?rev=2298869)
 * [JWT Auth - WordPress JSON Web Token Authentication](https://wordpress.org/plugins/jwt-auth/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/jwt-auth/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/jwt-auth/)
 * [Active Topics](https://wordpress.org/support/plugin/jwt-auth/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/jwt-auth/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/jwt-auth/reviews/)

 * 26 replies
 * 10 participants
 * Last reply from: [iperez_genius](https://wordpress.org/support/users/iperez_genius/)
 * Last activity: [4 years, 11 months ago](https://wordpress.org/support/topic/whitelisting-endpoints-function-do-not-work/page/2/#post-14648078)
 * Status: resolved