Laravel Passport: Target [Lcobucci\JWT\Parser] is not instantiable while building [Laravel\Passport\PersonalAccessTokenFactory]

五迷三道 提交于 2021-01-27 13:50:24

问题


It's my first time trying out this package and I followed the installation guide at https://laravel.com/docs/8.x/passport but when this code block in my controller signup action it throws the error:

$token = $user->createToken('authToken')->accessToken;

Here's the code for my signup action:

public function signup(Request $request){
    $request->validate([
        'name' => 'required',
        'email' => 'required|string|email:rfc,dns|unique:users',
        'password' => 'required|string|confirmed'
    ]);

    $user = new User([
        'name' => $request->name,
        'email' => $request->email,
        'password' => bcrypt($request->password)
    ]);

    $user->save();

    $token = $user->createToken('authToken')->accessToken;

    return response()->json([
        'message' => 'Successfully created user!',
        'access_token' => $token
    ], 201);
}
  • Passport Version: 10.0
  • Laravel Version: 8.16.1
  • PHP Version: 7.4.13
  • Database Driver & Version: MySQL 5.7.24

回答1:


I found the solution on: https://github.com/laravel/passport/issues/1381.

In composer.json just add "lcobucci/jwt": "3.3.3" and execute composer update.



来源:https://stackoverflow.com/questions/65017721/laravel-passport-target-lcobucci-jwt-parser-is-not-instantiable-while-buildin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!