I am using Laravel 7.5.2 with Vuejs. I am using passport for api authentication. I have followed passport installation instruction on laravel website.
- Has run composer require laravel/passport, php artisan migrate and php artisan passport:install
- Has added HasApiTokens in user model
- Has added Passport::routes() in AuthServiceProvider
- Has added \Laravel\Passport\Http\Middleware\CreateFreshApiToken::class in App\Http\Kernel web middlewareGroups
- Has changed Api driver to passport in config/auth.php
The cookie named "laravel_token" is getting generated and sent with ajax request as I can see in developer tool.
In my controller I have included api middleware as
public function __construct(){
$this->middleware('auth:api');
}
Api/Ajax Response
{
"message": "Undefined index: aud",
"exception": "ErrorException",
"file": "E:\\laravel\\vendor\\laravel\\passport\\src\\Guards\\TokenGuard.php",
"line": 140,
"trace": [
{
...
}
]
I have also tried: composer dump-autoload
My Setup
- Laravel: 7.5.2
- Passport: 9.0
- PHP : 7.4.0
- Vuejs: 2.5.17
The issue is not only related to vuejs. It's related to ajax requests from simple javascript or could be from any framework.