Describe your issue here.
| Q | A
| ----------------- | ---
| Bug? | no
| New Feature? | no
| Framework | Lumen
| Framework version | 5.6.*
| Package version | 2.0.x-dev
| PHP version | 7.x.y
tried to use it on Lumen like this
config(['auth.guards.api.driver' => 'jwt' ,'auth.defaults.guard' => 'api' , 'auth.defaults.passwords' => 'users' , 'auth.guards.api.provider' => 'users']);
and all other stuff ,with a Model like this:
class User extends Model implements JWTSubject
{
/**
* The users table.
*
* @var string
*/
protected $table = 'users';
...
...
...
/**
* Get the identifier that will be stored in the subject claim of the JWT.
*
* @return mixed
*/
public function getJWTIdentifier()
{
return $this->getKey();
}
/**
* Return a key value array, containing any custom claims to be added to the JWT.
*
* @return array
*/
public function getJWTCustomClaims()
{
return [];
}
}
Attempt to login
this error
Type error: Argument 2 passed to Tymon\JWTAuth\JWTGuard::__construct() must be an instance of Illuminate\Contracts\Auth\UserProvider, null given, called in /home/vagrant/sites/Lument/vendor/tymon/jwt-auth/src/Providers/AbstractServiceProvider.php on line 87
In config/auth.php does your specified guard provider match one of your declared providers?
So my config is as follows:
``````
'defaults' => [
'guard' => env('AUTH_GUARD', 'api'),
'passwords' => 'users',
],
'guards' => [
'api' => [
'driver' => 'jwt',
'provider' => 'users'
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
]
],
``````
I have faced the same issue and after adding the config/auth.php file it fixed :)
Thanks, my bad
Thank so much, you save my times
In
config/auth.phpdoes your specified guardprovidermatch one of your declaredproviders?So my config is as follows:
'defaults' => [ 'guard' => env('AUTH_GUARD', 'api'), 'passwords' => 'users', ], 'guards' => [ 'api' => [ 'driver' => 'jwt', 'provider' => 'users' ], ], 'providers' => [ 'users' => [ 'driver' => 'eloquent', 'model' => App\User::class, ] ],
Thanks man 馃憣
Most helpful comment
In
config/auth.phpdoes your specified guardprovidermatch one of your declaredproviders?So my config is as follows:
``````
'defaults' => [
'guard' => env('AUTH_GUARD', 'api'),
'passwords' => 'users',
],
``````