Error setting up Passport in Laravel

1

I have a laravel API and in it, I need to authenticate access requests. So I used Passport Laravel, but according to the API return, there is some definition that I did not report in my code.

In my route, I type the middleware type:

Route::get('/members', 'PessoaController@index')->middleware('auth:api');

In config / app.php I informed the class

 Laravel\Passport\PassportServiceProvider::class,
    Laravel\Passport\Http\Middleware\CreateFreshApiToken::class,

But when I make any requests in my API, I have the following return:

  

(1/1) FatalThrowableError    Type error: Argument 1 passed to Laravel \ Passport \ Http \ Middleware \ CreateFreshApiToken :: __ construct () must be an instance of Laravel \ Passport \ ApiTokenCookieFactory, instance of Illuminate \ Foundation \ Application given, called in /home/secbase.com. br / vendor / laravel / framework / src / Illuminate / Foundation / ProviderRepository.php on line 208

    
asked by anonymous 17.06.2018 / 17:52

2 answers

0

Have you injected trait Laravel\Passport\HasApiTokens into your class User ?

use Laravel\Passport\HasApiTokens;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use HasApiTokens, Notifiable;
}

Recorded passport routes in AuthServiceProvider ?

public function boot()
{
  $this->registerPolicies();

  Passport::routes();
}

link

    
17.06.2018 / 18:47
0

Is not the construct missing?

public function __construct()
{
    $this->middleware('guest', ['except' => 'getLogout']);
}
    
18.06.2018 / 14:00