I've been working in this application for several years and while doing some updates my passport authentication broke. I update from passport 7.2 to 7.5 and it broke. I then updated to passport 8.5 and it still doesn't work.
I am getting the 401 {error: "Unauthenticated."}
error.
I am using
- Laravel 7.28.1
- Passport 8.5.0
- Laravel Valet
- PHP 7.3
I am attempting to consume my own api and I've followed every solution I found on the internet, but no dice. I can access the routes using postman with an access token and if I move the route outside of the auth:api
middleware, but I want to access the routes within the auth:api
Here is my current config.
AuthServiceProvider.php
public function boot()
{
Passport::routes();
}
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
... other middleware
\Laravel\Passport\Http\Middleware\CreateFreshApiToken::class,
],
'api' => [
'throttle:60,1',
'bindings',
],
];
In auth.php
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'passport',
'provider' => 'users',
'hash' => false,
],
]
]
bootstrap.js
window.axios = require('axios');
window.axios.defaults.headers.common = {
'X-CSRF-TOKEN' : document.querySelector('meta[name="csrf-token"]').getAttribute('content'),
'X-Requested-With': 'XMLHttpRequest'
};
in a component.vue file
axios.get('/api/users?page=' + page).then((response) => {
//
})
I've cleared configs and ran php artisan optimize:clear
and about a dozen of other things that I can't thing of right now.
Any help would be appreciated.
{error: "Unauthenticated."}
error – Juan Rangel