title: Laravel Passport Get Client ID By Access Token
body: <p>I'm writing a tiny sms gateway to be consumed by a couple of projects,</p>
  
  <p>I implemented laravel passport authentication (<a href="https://laravel.com/docs/5.4/passport#client-credentials-grant-tokens" rel="noreferrer">client credentials grant token</a>)</p>
  
  <p>Then I've added <code>CheckClientCredentials</code> to api middleware group:</p>
  
  <pre><code>protected $middlewareGroups = [
      'web' =&gt; [
         ...
      ],
  
      'api' =&gt; [
          'throttle:60,1',
          'bindings',
          \Laravel\Passport\Http\Middleware\CheckClientCredentials::class
      ],
  ];
  </code></pre>
  
  <p>The logic is working fine, now in my controller I need to get client associated with a valid token.</p>
  
  <p><strong>routes.php</strong></p>
  
  <pre><code>Route::post('/sms', function(Request $request) {
      // save the sms along with the client id and send it
  
      $client_id = ''; // get the client id somehow
  
      sendSms($request-&gt;text, $request-&gt;to, $client_id);
  });
  </code></pre>
  
  <p>For obvious security reasons I can never send the client id with the consumer request e.g. <code>$client_id = $request-&gt;client_id;</code>.</p>