title: WordPress and JWT with custom API Rest Endpoint
body: <p>I need to provide a plugin for WordPress that will have few custom API endpoints, and I have installed these two plugins</p>
  
  <ul>
  <li><a href="https://me.wordpress.org/plugins/jwt-authentication-for-wp-rest-api/" rel="nofollow noreferrer">WordPress REST API V2</a></li>
  <li><a href="https://me.wordpress.org/plugins/jwt-authentication-for-wp-rest-api/" rel="nofollow noreferrer">JWT-Auth</a></li>
  </ul>
  
  <p>I have created custom endpoint:</p>
  
  <pre><code>add_action('rest_api_init', function ($data) {
      register_rest_route('mladi-info/v1', '/user/favorites', [
          'methods' =&gt; 'GET',
          'callback' =&gt; 'mi_get_favorite_posts'
      ]);
  });
  </code></pre>
  
  <p>I need to protect this endpoint so that only those requests that has JWT token sent (generated with /wp-json/jwt-auth/v1/token endpoint sending username and password) can be processed, otherwise it should return 401 status codes. How do I do that?</p>