title: tymon/jwt-auth for laravel 5.4 refresh token
body: <p>I recently using laravel 5.4 and I want to use tymon/jwt-auth package to secure my APIs by sending the access token but my issues happened when token expired I can't refresh it before expired and I expected the token will be refreshed automatically</p>
  
  <hr>
  
  <pre><code>public function handle($request, Closure $next)
  {
      try{
          $user = JWTAuth::parseToken()-&gt;authenticate();
      }catch (JWTException $e) {
          if($e instanceof \Tymon\JWTAuth\Exceptions\TokenExpiredException) {
              return response()-&gt;json(['token_expired'], $e-&gt;getStatusCode());
          }else if ($e instanceof \Tymon\JWTAuth\Exceptions\TokenInvalidException) {
  
              return response()-&gt;json(['token_invalid'], $e-&gt;getStatusCode());
          }else{
              return response()-&gt;json(['error'=&gt;'Token is required']);
          }
      }
     return $next($request);
  }
  </code></pre>