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.
composer require laravel/passport
php artisan migrate
app/model >
users.php
file changeuse Laravel\Passport\HasApiTokens; use HasApiTokens, Notifiable, SoftDeletes, HasRoles, HasFactory;
config >
auth.php
My Guards be like'api' => [ 'driver' => 'passport', 'provider' => 'users', ],
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