title: Automatically refresh access token with laravel passport
body: <p>When issuing access and refresh tokens I send them to the frontend with <code>httpOnly = true</code>. I made a middleware class which checks if the access token has expired and if the refresh token hasn't expired. If both are the case I call the oauth/token route with refresh_token as grant_type.</p>
  <p>All of this works, however I'm not sure how to use the authenticated user inside the controllers. Right now I've set the middleware up that when there's a response it sends the new access and refresh token.</p>
  <pre><code>class RefreshAccessToken
  {
      /* @var AuthController $authController */
      private $authController;
  
      /**
       * RefreshAccessToken constructor.
       *
       * @param AuthController $authController
       */
      public function __construct(AuthController $authController)
      {
          $this-&gt;authController = $authController;
      }
  
      /**
       * Handle an incoming request.
       *
       * @param \Illuminate\Http\Request $request
       * @param \Closure                 $next
       * @return mixed
       */
      public function handle($request, Closure $next)
      {
          // User already has an access token
          if ($request-&gt;hasCookie('access_token')) {
              return $next($request);
          }
  
          // User doesn't have an access token and doesn't have a refresh token.
          if (!$request-&gt;hasCookie('refresh_token')) {
              return $next($request);
          }
  
          $response = $next($request);
  
          $cookies = $this-&gt;authController-&gt;refreshToken($request);
  
          return $response
              -&gt;cookie($cookies['access_token'])
              -&gt;cookie($cookies['refresh_token']);
      }
  }
  </code></pre>
  <p>Now inside a controller if I want to access the logged in user I always get null as a response:</p>
  <pre><code>public function logout()
      {
          dd(auth()-&gt;user());
      }
  }
  </code></pre>
  <p>Inside the controller's construct method:</p>
  <pre><code>$this-&gt;middleware('auth:api')-&gt;only('logout');
  </code></pre>
  <p>Does anyone know how to handle this use case?</p>