title: Laravel default guard api - use web guard for login route
body: <p>how to change the guard for a special route?</p>
  
  <p>i've configured the api guard as default</p>
  
  <pre><code>  'defaults' =&gt; [
          'guard' =&gt; 'api',
          'passwords' =&gt; 'users',
      ],
  </code></pre>
  
  <p>now i've a route /login to authenticate the user with basic.once and send back the api token</p>
  
  <pre><code>Route::get('/login', ['middleware' =&gt; 'auth.basic.once', 'uses' =&gt; 'ApiController@login']);
  </code></pre>
  
  <p>with the following error</p>
  
  <pre><code>ErrorException in AuthManager.php line 288:
  call_user_func_array() expects parameter 1 to be a valid callback, class 'Illuminate\Auth\TokenGuard' does not have a method 'onceBasic'
  </code></pre>
  
  <p>as he try to use the default api guard...</p>
  
  <p>i want to keep api as default guard, just want to use web/auth.basic.once for the single /login route</p>
  
  <p><em>EDIT</em></p>
  
  <pre><code>'auth.basic.once' =&gt; \App\Http\Middleware\AuthenticateOnceWithBasicAuth::class,
  
  namespace App\Http\Middleware;
  
  use Closure;
  //use Auth;
  use Illuminate\Support\Facades\Auth;
  
  class AuthenticateOnceWithBasicAuth
  {
      /**
       * Handle an incoming request.
       *
       * @param  \Illuminate\Http\Request  $request
       * @param  \Closure  $next
       * @return mixed
       */
      public function handle($request, Closure $next)
      {
          return Auth::onceBasic() ?: $next($request);
      }
  }
  </code></pre>
  
  <p>this is from the laravel 5.2 documentation <a href="https://laravel.com/docs/5.2/authentication" rel="nofollow">https://laravel.com/docs/5.2/authentication</a></p>
  
  <p>thanks</p>