config/auth.php
for Passport
Ensure you have configured the guards
for Passport in the config/auth.php
file. Refer to the example below:'api' => [
'driver' => 'passport', /** For Passport */
'provider' => 'users2',
],
Set up providers in config/auth.php
for Passport
Configure the providers
in the config/auth.php
file for Passport. Here's an example:
'users2' => [
'driver' => 'eloquent',
'model' => env('AUTH_MODEL', App\Models\User::class),
],
Generate Passport keys Ensure the Passport keys are generated in the following paths:
storage/oauth-private.key
storage/oauth-public.key
Assign the appropriate permissions to these files, such as 600
.
Manually generate keys if not created automatically If the keys are not generated automatically, you can forcefully generate them using the following command:
php artisan passport:keys --force
Load Passport keys in the AppServiceProvider
In the boot
method of app/Providers/AppServiceProvider.php
, load the Passport keys as shown below:
public function boot(): void
{
Passport::loadKeysFrom(base_path('storage'));
}
Clear cache and restart the application After completing the above steps, clear the cache using:
php artisan optimize:clear
Then, restart your Laravel application.
If you encounter any issues after these configurations, feel free to comment below. I’ll be happy to assist you!