title: Setting up Laravel's OAuth 2.0 is Dingo API
body: <p>I use Laravel 5.3 with Dingo API, and I'm trying to get Laravel's OAuth 2.0 (aka Passport) to work with Dingo's Authentication.</p>
  
  <p>I added the OAuth 2.0 provider in <code>config/api.php</code>, which I found <a href="https://github.com/dingo/api/issues/219" rel="nofollow noreferrer">here</a>:</p>
  
  <pre><code>'auth' =&gt; [
      'oauth' =&gt; function($app) {
          $provider = new Dingo\Api\Auth\LeagueOAuth2Provider($app['oauth2.resource-server']);
  
          $provider-&gt;setUserCallback(function($id) {
              return User::find($id);
          });
  
          $provider-&gt;setClientCallback(function($id) {
              return Client::find($id);
          });
          return $provider;
      }
  ]
  </code></pre>
  
  <p>And then I added the <code>api.auth</code> middleware onto my route:</p>
  
  <pre><code>$api = app('Dingo\Api\Routing\Router');
  
  $api-&gt;version('v2', function($api) {
      # ...
      $api-&gt;get('test', ['middleware' =&gt; 'api.auth', 'App\Http\Controllers\v2\SnippetController@test']);
  });
  </code></pre>
  
  <p>And when request the <code>/api/test</code>, I get a <code>500</code> HTTP response with this error:</p>
  
  <pre><code>Call to undefined method Closure::authenticate()
  </code></pre>
  
  <p>The full JSON response (which includes the trace) can be found <a href="https://pybin.pw/WIobIQNB" rel="nofollow noreferrer">here</a></p>
  
  <p>Sadly <a href="https://github.com/dingo/api/wiki/Authentication#oauth-20" rel="nofollow noreferrer">the docs</a> barely mention setting up Dingo with <code>league/oauth2-server</code>, which is what Laravel uses</p>