Skip to content

Laravel 7.5.2 (Passport Api) + Vuejs Error : Undefined index: aud , \vendor\laravel\passport\src\Guards\TokenGuard.php #1243

Closed
@mhabib555

Description

@mhabib555
  • Passport Version: 9.0
  • Laravel Version: 7.5.2
  • PHP Version: 7.4.0
  • Database Driver & Version:
  • Database client version: libmysql - mysqlnd 7.4.0

Description:

I am using Laravel 7.5.2 with Vuejs. I am using passport for api authentication. I am getting the following error when sending ajax request to api

{
"message": "Undefined index: aud",
"exception": "ErrorException",
"file": "E:\\laravel\\vendor\\laravel\\passport\\src\\Guards\\TokenGuard.php",
"line": 140,
"trace": [
    {
...
}
]

Steps To Reproduce:

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');
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions