title: How to get logged in user information using JWT Authentication?
body: <p>In my WordPress REST API project i need to get logged in user data through api. I used the <a href="https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/" rel="nofollow noreferrer">JWT Authentication for WP REST API</a> plugin for generating tokens. I have generated tokens with the parameters of  username and password of the user. <a href="https://i.stack.imgur.com/YzZmH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YzZmH.png" alt="enter image description here"></a></p>
  
  <p>Now using this tokens i have create one function in my api file but it sends me <code>0</code> as api response in postman with these below Headers. </p>
  
  <pre><code>'Content-type': 'application/json', 
  'Authorization': 'Bearer token_value'
  </code></pre>
  
  <p>Function code: </p>
  
  <pre><code>function get_loggedin_user_info(){
    global $current_user; 
  
    $current_user = wp_get_current_user();
    print_r($current_user);
  }
  
  add_action( 'rest_api_init', function () {
      register_rest_route( 'endpoints/v1', '/logininfo', array(
              'methods' =&gt; 'POST',
              'callback' =&gt; 'get_loggedin_user_info'
      ));
  });
  </code></pre>
  
  <p>So how can i get the logged in users data with the WordPress hook <code>wp_get_current_user()</code></p>
  
  <p>Secondly, how can i make make the <code>jwt-auth/v1/token</code> API that will get the username and password as dynamic ?  </p>
  
  <p>P.S I have add the RewriteCond and RewriteRule in the htacceess file and also includes the JWT Auth Secret key in my config file. </p>
  
  <pre><code>define('JWT_AUTH_SECRET_KEY', 'secret-key');
  define('JWT_AUTH_CORS_ENABLE', true);
  </code></pre>