laravel passport : registered date claims is deprecated

Viewed 3298

I'm trying to utilize laravel passport for api authentication

 $user = User::create([
            'first_name' => $request->firstName,
            'last_name' =>  $request->lastName,
            'email' => $request->email,
            'password' => Hash::make($request->password),
            'verified' => User::UNVERIFIED_USER,
            'capacity' => User::REGULAR,
            'verification_token' => User::generateVerificationToken(),
        ]);

        $token = $user->createToken('Laravel Password Grant Client')->accessToken;
        return response()->json(['data' => $token]);


and I'm getting this error:

    "message": "Method Laravel\\Passport\\Bridge\\AccessToken::__toString() must not throw an exception, caught ErrorException: Using integers for registered date claims is deprecated, please use DateTimeImmutable objects instead.",
    "exception": "Symfony\\Component\\ErrorHandler\\Error\\FatalError",
    "file": "C:\\xampp\\htdocs\\laravel\\crowdfund\\vendor\\league\\oauth2-server\\src\\ResponseTypes\\BearerTokenResponse.php",
    "line": 0,
    "trace": []

How do I solve this?

2 Answers

It's a known issue. The solution is to downgrade the lcobucci/jwt dependency to version ~3.3.0.

You can directly run the below command in your terminal.

composer require lcobucci/jwt 3.3.3

Then check with your passport API authentication

Related