title: Laravel API - Argument 1 passed to TokenGuard::__construct() must implement interface UserProvider
body: <p>REST-API in Laravel 8 using <a href="https://laravel.com/docs/5.8/api-authentication#configuration" rel="nofollow noreferrer">API Authentication</a>.</p>
  <p><strong>Introduction</strong></p>
  <p>I have <code>Analytics</code> Model Authenticable to authenticate the request in web rather than using default <code>User</code> Model  with corresponding <code>analytics</code> and <code>user</code> table table. I have migrated <code>api_token</code> field in <code>analytics</code> table. However, I'm getting below error in response while accessing the API route in POSTMAN.</p>
  <p><strong>Response</strong></p>
  <pre><code>{
  &quot;message&quot;: &quot;Argument 1 passed to Illuminate\\Auth\\TokenGuard::__construct() must implement interface Illuminate\\Contracts\\Auth\\UserProvider, null given, called in source\\vendor\\laravel\\framework\\src\\Illuminate\\Auth\\AuthManager.php on line 162&quot;,
  &quot;exception&quot;: &quot;TypeError&quot;,
  }
  </code></pre>
  <p><strong>source\vendor\laravel\framework\src\Illuminate\Auth\AuthManager.php on line 162</strong></p>
  <pre><code>    public function createTokenDriver($name, $config)
      {
          $guard = new TokenGuard(
              $this-&gt;createUserProvider($config['provider'] ?? null),
              $this-&gt;app['request'],
              $config['input_key'] ?? 'api_token',
              $config['storage_key'] ?? 'api_token',
              $config['hash'] ?? false  // **** This is line 162 **** //
          );
  
  </code></pre>
  <p>I tried changing line 162 as <code>$config['hash'] ?? true</code> but still getting same error.</p>
  <blockquote>
  <p><strong>Note:</strong> The <code>Analytics</code> and <code>User</code> Model are <strong>Authenticable</strong>. While I have the <code>api_token</code> field in the <code>analytics</code> table</p>
  </blockquote>
  <p><strong>Request:</strong></p>
  <p>I'm sending <code>GET</code> instance of HTTP Request on endpoint
  <code>http://example.com/api/user?api_token=token(this is unhashed token)</code></p>
  <p><strong>Below is the following configuration.</strong></p>
  <p><code>route/api.php</code></p>
  <pre><code>Route::middleware('auth:api')-&gt;get('/user', function (Request $request) {
      return $request-&gt;user();
  });
  </code></pre>
  <p>The <code>Analytics</code> and <code>User</code> Model are follow:</p>
  <pre><code>&lt;?php
  
  namespace App;
  use Illuminate\Notifications\Notifiable;
  use Notification;
  use Illuminate\Foundation\Auth\User as Authenticatable;
  use App\Notifications\AnalyticsResetPassword;
  use Illuminate\Database\Eloquent\Model;
  
  class Analytics extends Authenticatable
  {
      use Notifiable;
      public function sendPasswordResetNotification($token)
      {
          $this-&gt;notify(new AnalyticsResetPassword($token));
      }
  
      protected $table = &quot;analytics&quot;;
  
      protected $fillable = ['name', 'email', 'password', 'mobile', api_token', ];
  
      protected $hidden = ['password', 'api_token', 'remember_token', ];
  }
  
  </code></pre>
  <pre><code>&lt;?php
  
  namespace App;
  
  use Illuminate\Notifications\Notifiable;
  use Illuminate\Contracts\Auth\MustVerifyEmail;
  use Illuminate\Foundation\Auth\User as Authenticatable;
  
  class User extends Authenticatable
  {
      use Notifiable;
  
      protected $fillable = ['name', 'email', 'password', ];
  
      protected $hidden = ['password', 'remember_token',];
  
      protected $casts = ['email_verified_at' =&gt; 'datetime',];
  }
  
  </code></pre>
  <p>The <code>guard</code> and <code>provider</code> array in <code>config/auth.php</code> configuration file:</p>
  <pre><code>    'guards' =&gt; [
          
          'web' =&gt; [
              'driver' =&gt; 'session',
              'provider' =&gt; 'users',
          ],
  
          'analytics' =&gt; [
              'driver' =&gt; 'session',
              'provider' =&gt; 'analytics',
          ],
  
          'api' =&gt; [
              'driver' =&gt; 'token',
              'provider' =&gt; 'user',
              'hash' =&gt; true,
          ],
      ],
  
      'providers' =&gt; [
  
          'users' =&gt; [
              'driver' =&gt; 'eloquent',
              'model' =&gt; App\User::class,
          ],
  
          'analytics' =&gt; [
              'driver' =&gt; 'eloquent',
              'model' =&gt; App\Analytics::class,
          ],
      ],
  </code></pre>
  <p>The token generating method in Controller</p>
  <pre><code>    public function token(Request $request)
      {
          $token = Str::random(60);
          $user = Auth::user();
          $user-&gt;api_token = hash('sha256', $token);
          $user-&gt;save();
          return redirect('/analytics/security')-&gt;with('success', 'Token Generated Successfully!')-&gt;with(&quot;token&quot; , $token);
      }
  
  </code></pre>