php - Unauthenticated in Laravel Passport while fetching data

one text

I tried following steps for install passport authentication for my api's. but i get everytime {"error":"Unauthenticated."} while fetching simple data.

  1. composer require laravel/passport

  2. php artisan migrate

  3. app/model > users.php file change

    use Laravel\Passport\HasApiTokens; use HasApiTokens, Notifiable, SoftDeletes, HasRoles, HasFactory;

  4. config > auth.php My Guards be like

    'api' => [
        'driver' => 'passport',
        'provider' => 'users',
    ],
    
  5. providers > AuthServiceProvider.php

    if (! $this->app->routesAreCached()) {
        Passport::routes();
    }
    

Note :

  • i tried almost all relatable solutions on stackoverflow as well laracast. Still not able to find the solution.
  • I've Laravel 7 earlier and i upgraded to Laravel 8. and i also checked for updating dependencies
  • My Login url http://127.0.0.1:8000/api/login works perfectly and returning a bearer token successfully
  • i've also passed Accept : application/json & Authorization : Bearer <MY_BEARER_TOKEN> in postman request

Source