rakk92
rakk92

Reputation: 67

Laravel Passport 'App\\User' not found?

My 'User' model is inside 'App\Models\User.php', and when I do this:

    use GuzzleHttp\Client;

    $client = new Client();
    $response = $client->request('POST', 'http://localhost/oauth/token', [
        'form_params' => [
        'username'      => $data['username'],
        'password'      => $data['password'],
        'client_id'     => env('PASSWORD_CLIENT_ID'),
        'client_secret' => env('PASSWORD_CLIENT_SECRET'),
        'grant_type'    => 'password'
      ]
    ]);

Iam getting this error:

"message": "Server error: `POST http://localhost/oauth/token` resulted in a `500 Internal Server Error` response:\nClass 'App\\User' not found\n",

It seems Passport is looking for 'User' model inside 'App' directory, not the 'Model' directory which is the right place.

How to solve this ?

Upvotes: 1

Views: 1179

Answers (2)

Jonathon
Jonathon

Reputation: 16333

Make sure you update the model class name in your config/auth.php file:

'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => App\Models\User::class,
    ],
]

Upvotes: 0

common sense
common sense

Reputation: 3912

In your config/auth.php file search for the providers key and change the model from App\User::class to App\Model\User::class:

'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => App\Model\User::class, // <-- this line
    ],

    //
],

Then delete the configuration cache via php artisan config:clear.

Upvotes: 3

Related Questions